new syntax - a provocation
Wed Sep 24 11:24:01 CEST 2003
Joe Armstrong <joe@REDACTED> writes:
> On Tue, 23 Sep 2003, Chris Pressey wrote:
> > > << The *easiest* way to do "Atom table GC" is not to have an
> > > atom
> > > table in the first place - redesign Erlang so that it does
> > > not need an atom table - this is "relatively" easy >>
> > Yes, but can you still ensure constant time operations on atoms?
> There are two ways of doing this:
Atoms are unique objects just like from make_ref() but with names.
There is a global hashtable for list_to_atom/1 to find (or create)
the atom with a particular name.
All references to atoms from beam files, binary_to_term, etc, are
resolved by list_to_atom/1.
References from the atom table to the atom objects are "weak",
i.e. are not used to mark atoms as live during garbage collection.
When an atom is garbage collected, it is removed from the hash
table. If someone later wants an atom with the same name, a new one
is created which is then the only existing atom with that name.
Then if there are no references to an atom (except from the atom
table) it is garbage collected and forgotten. So long as there are N>0
references to a particular atom, they all refer to the same object and
can be compared in unit time.
(Oops. Did I just assume a unified heap, or separate space for atoms?)
More information about the erlang-questions