system messages (Re: Suggested Example/ emacs questions)

Ulf Wiger etxuwig@REDACTED
Tue Oct 10 11:43:25 CEST 2000


I've made several false-starts trying to improve the system 
messages situation.

One idea has been to do a parse transform, looking for e.g.
'system_receive' instead of 'receive', and then inserting a match on
system messages. It's not that hard to store needed information in the
process dictionary, so that the necessary info can be extracted and
passed to the sys:handle_system_msg/6 function.

A problem then becomes what to do with a module that contains receive
statements, but no system_receive. It might be appropriate to leave
them alone.

Another problem arises with the shutdown protocol. I'd like to also
insert a match for {'EXIT', Parent, shutdown} in the system_receive,
but I don't have Parent available...

... actually, I would, if I were allowed to use get and put in guards:

receive
   {'EXIT', Parent, shutdown} when Parent == hd(get('$ancestors')) ->
      shutdown(...);
   ...
end.


Since get() and put() are O(1) nowadays, why can't I use them in
guards?


/Uffe


On 10 Oct 2000, Luke Gorrie wrote:

>Ulf Wiger <etxuwig@REDACTED> writes:
>
>> System messages are much harder. How to accomplish the suspend/
>> code_change/resume functionality, as well as the ordered shutdowns,
>> without messing up the normal program?
>> 
>> I've been wishing for some kind of "protected mode" section, where
>> I can write hooks to modify message reception; system messages 
>> would then be somehow pre-empted by OTP, unless I explicitly state
>> that I want to see them.
>
>Another dubious possibility I was thinking of is inline'ing all the
>system message handling with a macro, like:
>
>  receive
>    pop when Empty == false -> ...;
>    {push, Item} when Full == false -> ...;
>    ?handle_system_messages
>  end
>
>Just what that macro would expand to, I've no firm idea :-)
>
>Using non-trivial macros in Erlang doesn't feel good, though.
>
>-Luke
>
>

-- 
Ulf Wiger                                    tfn: +46  8 719 81 95
Network Architecture & Product Strategies    mob: +46 70 519 81 95
Ericsson Telecom AB,              Datacom Networks and IP Services
Varuvägen 9, Älvsjö,                    S-126 25 Stockholm, Sweden




More information about the erlang-questions mailing list