Concatenating atoms

Richard A. O'Keefe <>
Wed Feb 2 02:06:26 CET 2005


Thomas Lindgren <> wrote:
	It _would_ be useful to have some way to check whether
	an atom with a given name already exists. Compiler
	writers and other "gensym users" would appreciate it
	(at least some -- me -- would). 

I don't see how this would be useful.
    Process one:
        Does "XYZZY 27" exist?
        Oh good, no!
	<switch!>
    Process two:
	Does "XYZZY 27" exist?
	Oh good, no!
	Create 'XYZZY 27' as new gensym.
	<switch!>
    Process one:
	Create 'XYZZY 27' as new gensym.
	Use it as a "private" key in a table.
	<switch!>
    Process two:
	Use 'XYZZY 27' as a "private" key in a table.

Now two processes are both holding onto what they think is a new atom.
This is a classic concurrent programming bug resulting from unguarded
mutation of a global shared variable.

The Erlang answer is isolation, Isolation, ISOLATION!

Whatever the atom symbol table looks like, no process should be able
to detect *changes* to it due to the activity of other processes.

In any case, surely the Erlang equivalent of gensyms is 'references'?




More information about the erlang-questions mailing list