why does the process dictionary have a bad rep?
Fri Jul 15 17:43:33 CEST 2005
Den 2005-07-15 17:18:22 skrev ke.han <>:
> This thread is talking about two things: abuse of the proc dict and
> abuse of message passing.
> I understand the example of using the proc dict to get around single
> assignment. You guys have lost me on the second part.
> Can someone give an example of message passing abuse? What does message
> passing have to do with variable assignment?
> thanks, ke han
The things listed in the Erlang book about the process dictionary
apply equally to message passing.
- if a computation is rolled back by a catch, messages
sent during that computation cannot be rolled back
- if functions send messages (have side effects), the
order in which functions are called can become very
- understanding a single function is much easier if
it only depends on the input arguments, and not
on message passing inside the function. Without
side-effects, you know that the function will
always return the same result each time it's
called with a given set of arguments - regardless
of timing issues.
- verifying code that doesn't have side-effects is
also much easier, as the state space is radically
reduced. This is related to the previous point.
In general, it's a very good idea to isolate all
side-effects as much as possible, and to keep
them clearly separated from the code that can be
More information about the erlang-questions