Ulf Wiger (AL/EAB)
Tue Feb 22 13:01:15 CET 2005
As a general principle, you should make sure that your
atom-producing functions operate on a finite set of
In other words, if String in your example is something that
is received from the outside, you have an infinite set of
possible atoms, which is not good. Then, I would try to
re-write the code as:
a("hello") -> b(hello);
a("ciao") -> b(ciao);
a("bonjour") -> b(bonjour).
- if at all possible.
> -----Original Message-----
> From: owner-erlang-questions@REDACTED
> [mailto:owner-erlang-questions@REDACTED]On Behalf Of Corrado Santoro
> Sent: den 22 februari 2005 10:45
> To: erlang-questions@REDACTED
> Subject: Atom pollution
> Dear all,
> I've read that atoms are not garbage collected. But suppose I use the
> following code:
> a(String) -> b(list_to_atom(String)).
> b(hello) -> ...
> b(ciao) -> ...
> b(bonjour) -> ...
> String can be "hello", "ciao" or "bonjour".
> What happens each time a/1 is called? Is a new atom created
> each time or
> there is a sort of "atom hash"?
> Eng. Corrado Santoro, Ph.D.
> University of Catania - Engineering Faculty
> Department of Computer Science and
> Telecommunications Engineering
> Viale A. Doria, 6 - 95125 CATANIA (ITALY)
> Tel: +39 095 7382380 Fax: +39 095 7382397
> +39 095 7382365
> +39 095 7382364
> EMail: csanto@REDACTED
> Personal Home Page:
> NUXI Home Page:
More information about the erlang-questions