Meyer, OO and concurrency

Ulf Wiger <>
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.

9> c(procdict).
10> procdict:start().
11> procdict:put(a,17).
12> procdict:get(a).
13> procdict:get().
14> procdict:get(b).
15> procdict:put(a,147).

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 !
operator. ;-)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: procdict.erl
Type: application/octet-stream
Size: 2078 bytes
Desc: not available
URL: <>

More information about the erlang-questions mailing list