[erlang-questions] Erlang and mutable state

KatolaZ <>
Fri Nov 16 22:52:22 CET 2007


On Fri, Nov 16, 2007 at 04:36:34PM -0500, istarex wrote:
> Hi all,
> 
> I had a question about Erlang and mutable state.  I understand that
> Erlang avoids the concurrency nightmare of other languages by avoiding
> mutable state shared between processes.  But why Erlang doesn't allow
> mutable state isolated within a process (such that no other process
> could directly access or change that state)?  I'm wondering what in
> Erlang's programming model prevents this.  If anybody could point me
> to a good link or paper that describes the reason, I'd really
> appreciate it.
> 

I think the main reason is the functional origin of Erlang, aside with
the fact that native support for concurrency and message passing among
processes lead to a rather different way of seeing at "mutable
states": you just have a state of processes (such as the
usually-called LoopData or the state of a behaviour), and there is no
difference among mutable and immutable states.

All states are mutable in Erlang, and you're sure that a state does
not ever survive after the end of the corresponding process. I
understand this could be hard to deal with for those who come from an
imperative language, but as soon as you get acquainted with this new
way of looking at "variables", you'll probably find that "the
functional way" is much more simple and intuitive than the imperative
abstraction. :-)

HND

Enzo

-- 
[ Enzo Nicosia aka KatolaZ --- GLUG Catania -- Freaknet Medialab ]
[ me [at] katolaz.homeunix.net -- http://katolaz.homeunix.net -- ]
[ GNU/Linux User:#325780/ICQ UIN: #258332181/GPG key ID 0B5F062F ]
[ Fingerprint: 8E59 D6AA 445E FDB4 A153 3D5A 5F20 B3AE 0B5F 062F ]



More information about the erlang-questions mailing list