Meyer, OO and concurrency
Thu Jul 14 02:02:07 CEST 2005
Den 2005-07-14 00:47:11 skrev Richard A. O'Keefe <>:
> Even Erlang has the shameful process dictionary, but at least process
> dictionaries are private and cannot be modified by any other process.
(Mainly for the lurkers and beginners on the list)
I've argued before that I think process dictionaries have received
a bad reputation unjustly. They have the same basic semantics as
private ets tables, but have some nice advantages besides the obvious
advantage of convenience.
Attached is an incomplete (and inefficient) implementation of a process
dictionary, written in plain erlang. The inefficiency comes mainly
from the very naiive choice of access structures in the program,
not from the message passing (unless the key-value pairs are big
and we're not using shared or hybrid heap.)
There's nothing in the process dictionary that can't be implemented
with same semantics in plain erlang, using a registered process and
some message passing.
One might argue that it's wrong to make it so convenient
and efficient to use something like a process dictionary.
Of course, if the process communication can be made
arbitrarily fast, you can easily implement destructive
assignment of global variables in Erlang -- process
dictionary or no process dictionary. The culprit is the !
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 2078 bytes
Desc: not available
More information about the erlang-questions