process WORM dictionary

Ulf Wiger etxuwig@REDACTED
Thu Feb 22 15:57:03 CET 2001


Hi!

Here's a thought.

The much-berated process dictionary is very useful for certain
purposes, but in many cases, you'd want to use it in a way that you
put() an object into it once and then get() it many times.

The practice of using the process dictionary to continuously update a
set of "global variables" is rightfully discouraged (except this leads
people to create an ets table and use it for the same purpose, which
is no better -- actually worse in some ways.)

Here's an example of reasonable use of the process dictionary,
from proc_lib.erl:

init_p(Parent,Ancestors,M,F,A) ->
    put('$ancestors',[Parent|Ancestors]),
    put('$initial_call',{M,F,A}),
    Result = (catch apply(M,F,A)),
    exit_p(Result,M,F,A).

What I'm thinking is that there is no reason why it would be even
possible for a process to replace these values, by e.g. calling
put('$ancestors', NewValue). This is a form of structural information
that shouldn't be considered part of the process' metadata.

So, wouldn't it be better if there was a write-once dictionary for 
the process? I realize that there is an ambition to save bytes in the
process struct, but perhaps it could be implemented as a "sticky bit"
in the existing process dictionary?

Any attempt then to overwrite or erase a write-once object would
generate a runtime error.

/Uffe
-- 
Ulf Wiger                                    tfn: +46  8 719 81 95
Senior System Architect                      mob: +46 70 519 81 95
Strategic Product & System Management    ATM Multiservice Networks
Data Backbone & Optical Services Division      Ericsson Telecom AB




More information about the erlang-questions mailing list