system messages (Re: Suggested Example/ emacs questions)

Ulf Wiger etxuwig@REDACTED
Tue Oct 10 13:00:53 CEST 2000


On Tue, 10 Oct 2000, Robert Virding wrote:

>Ulf Wiger <etxuwig@REDACTED> writes:
>>
>>Since get() and put() are O(1) nowadays, why can't I use them in
>>guards?
>>
>
>The main requirement for what can go in guards is not really that it is 
>O(1) but that it must be side-effect free.  Which put/2 is not.

Yes, forget put() in guards.


>Personally I have always considered the process dictionary to be a
>BIG mistake and therefore feel we should do nothing which encourages
>it, like making it accessable in guards. :-)

Personally, I think that the process dictionary is no worse than using
a named protected ets table (which has almost the same
characteristics). Actually, the process dictionary is better in the
sense that you can see its contents in crash reports and using
process_info/1 or sys:get_status/1.

The fact that the process dictionary *is* used for some pretty
fundamental stuff (like proc_lib) indicates that it fills a gap.

BTW, for my original purpose, there would be other ways to solve it:
process_info(self(), parent), for example (but this isn't allowed in
guards either). 

Why wouldn't there be a way for me to use information like Parent,
RegisteredName, MessageQueueLen, ProcessPriority, in guards without
carrying them around as arguments or variables?

This is one important reason why a lot of manual work is required for
writing your own OTP behaviours: you can't write an efficient support
library without manual work, and it's even harder if you're not
allowed to use e.g. the process dictionary.

/Uffe
-- 
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