[erlang-questions] Process scope variable

Richard A. O'Keefe ok@REDACTED
Wed Feb 18 01:41:59 CET 2015


On 18/02/2015, at 9:38 am, Imants Cekusins <imantc@REDACTED> wrote:
> how about those process scope variables though? :-P
> more reliable than process dict.

No, they aren't.  They are essentially the same thing.

The process dictionary approach has one overwhelming advantage.
It has been part of Erlang for a long time.  It's there; it works;
you can use it NOW, and other Erlang programmers will know what
it means.

It has problems, but it can do the job, and the problems are a
helpful reminder that maybe the job should not be done.

> same principles as function scope
> variables: immutable, gc'ed when the process finishes.
> 
> would noone else use them?

Let's see: no 'process scope variables' in Concurrent ML;
no 'process scope variables' as such in Haskell;
nothing but painful experiences with 'thread local' variables in C; ...

Nope.  Not going to use them.  I would prefer to thread a
state record/map through 100 functions.

Give me a 'process' form that IS a syntactic scope, as in Ada,
where variables declared inside a 'task' are *naturally*
process-local and genuinely syntactically scope, and I have no
trouble with them.

One major issue for me is that "process scope" (gosh it grates
to use the word "scope" for something that is not a scope) is
not good enough.  Given such a thing, the next thing is to want
to introduce or revise a variable binding within the body of
some function and have the binding go away/revert when the
function is complete.  That is trivial when you are passing a
state record/map around.  With single-level "process scope"
variables, one starts demanding more machinery.





More information about the erlang-questions mailing list