Tue Feb 1 08:58:47 CET 2005
thomas.xa.johnsson@REDACTED (Thomas Johnsson XA LN/EAB) writes:
> There appears to be no cheaper way to concatenate two atom than
> list_to_atom(atom_to_list(Atom1) ++ atom_to_list(Atom2))
> ... or have I missed something?
> -- Thomas
You have to create a new atom that just happens to have a string
representation that is the concatenation of two other atoms
string representations in the runtime system.
All atoms have the same size; one machine word. It is like a unique
integer with a string representation. The entries in the atom
table may differ in size, but that is just one place in the
When you create an atom you have to first check that its string
representation does not already exist in the atom table and if
not create a new entry with a new unique integer.
The atom table has got a fixed max size, so creating atoms during
runtime is often not a good idea, unless it happens a limited
number of times. If creating new atoms with new different string
representations is a part of the normal application processing, the
atom table will be filled one day and the runtime system fails.
/ Raimo Niskanen, Erlang/OTP, Ericsson AB
More information about the erlang-questions