Impressions of Mozart-Oz

Vance Shipley vances@REDACTED
Sat Dec 14 01:43:06 CET 2002


James,

It's part of learning Erlang though isn't it?  We don't really want 
global variables any more than we want multiple assignment variables.
It's just a mindset that you must learn to get out of.  What is needed
is good tutorial text to demonstrate why we don't have them and how to
avoid needing them.  The following is a poor attempt:

Q:  Where are the global variables?

A:  There are none.  To accomplish what you want pass the data in
    arguments to function calls.  When using the standard behaviours
    use the State argument to store all data which must be persistent.
    Don't use the process dictionary.  To keep persistant data which
    must be accessed by more than one process use a server to provide
    access and updates to the data.  Use ETS to maintain system wide
    counters and tables.


	-Vance

On Fri, Dec 13, 2002 at 05:18:46PM -0600, James Hague wrote:
}  
}  And though I hate to say it, if Erlang had a few more imperative features
}  then I expect there'd be less resistance to it.  For example, it can be
}  pretty tough to explain to someone why they can't have a global updateable
}  array, especially when that's a basic feature in just about every other
}  language out there.  Or that you can only have global variables in general
}  through the process dictionary, a feature the Erlang book strongly warns
}  against using.  It's difficult to find *any* program in Python, Perl,
}  Scheme, Lisp, Ruby, etc., that doesn't use globals for infrequently updated
}  variables.
}  
}  James



More information about the erlang-questions mailing list