<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
On 10/10/2012 04:21 PM, Michael Truog wrote:
<blockquote cite="mid:507602F9.7080005@gmail.com" type="cite">
<meta http-equiv="Context-Type" content="text/html;
charset=ISO-8859-1">
On 10/10/2012 03:55 PM, Charles Hixson wrote:
<blockquote cite="mid:5075FCF2.6060502@earthlink.net" type="cite">I'm
choosing a language to implement a ... well, neural network is
wrong, and so is cellular automaton, but it gives the idea.
Anyway, I'm going to need, in each cell, a few stateful items,
e.g. activation level. <br>
<br>
When I look at what Erlang can do, I see that the Process
Dictionary looks as if it would serve my needs, but then I am
immediately warned not to use it, that it will cause bugs.
These stateful terms will not be exported from the cell within
which they are resident. Is this still likely to cause
problems? Is there some better approach to maintaining state?
(I can't just generate a new process, because other cells will
need to know how to access this one, or to test that it has been
rolled out.) <br>
<br>
</blockquote>
<tt>This explains some basics about the process dictionary: </tt><a
moz-do-not-send="true"
href="http://www.erlang.org/course/advanced.html#dict">http://www.erlang.org/course/advanced.html#dict</a><br>
Quoted below:<br>
<ul>
<li>Destroys referential transparency </li>
<li>Makes debugging difficult </li>
<li>Survives Catch/Throw</li>
</ul>
So, it is much better to use variables, so side-effects are more
explicit (i.e., function variables). This is the equivalent to
the State variable of a gen_server behaviour (<a
moz-do-not-send="true"
href="http://www.erlang.org/doc/man/gen_server.html">http://www.erlang.org/doc/man/gen_server.html</a>).
Depending on the expected state-handling, you might want a
gen_server, a gen_event, or a gen_fsm for each cell. Otherwise,
if you want to avoid OTP behaviour usage, you could just do plain
Erlang code, but your code might then be more error-prone
(especially since you are asking this question).<br>
<br>
</blockquote>
Thank you. That confirms the recommendation against using the
process directory, though I will admit that I can't see any way that
your proposed alternatives could replace it.<br>
<br>
<pre class="moz-signature" cols="72">--
Charles Hixson</pre>
</body>
</html>