Meyer, OO and concurrency

Ulf Wiger <>
Fri Jul 15 10:01:56 CEST 2005


Den 2005-07-15 08:44:42 skrev Valentin Micic:

> because of this *reputation*, I've been avoiding dictionary
> (BIFs put & get),  for a long time. Recently, I did some
> ad-hoc measurement, and noticed that dictionary migt be
> considerably faster in accessing data than ets -- possibly
> because data from dictionary are passed by reference, wheres ets
> has to reply with message. What are the limitations of dictionary,
> and *why* it received a bad reputation?

I think it was frowned upon as early as in the Erlang book (chapter
8.6, where its use is discouraged), since it breaks referential
transparency (it introduces side effects in your functions.)
This is a fair warning, since it's tempting to use process
dictionaries as a means to get global variables.

I guess what's missing is a really good treatment of side effects,
and how to manage them properly. As side effects, you should at
least count message passing, spawn, link & monitor, the register
BIFs, the port BIFs, the process dictionary, ets, dets file,
disk_log, mnesia.

All of them can be viewed as based on the basic process concept
and message passing. And just about everything that's said to be
bad about the process dictionary can be applied to message
passing in general. The Erlang book never warns the user to
take care with messages in the same fashion, and certainly
doesn't discourage the use of them. (:

/Uffe




More information about the erlang-questions mailing list