How do Erlang atoms work?

Viewed 1729

Trying to find documentation on details, I did not find a lot beyond:

  • There is a (erlang runtime instance-) atom table.
  • Atom string literal is only stored once.
  • Atoms take 1 word.

To me, this leaves a lot of things in the unclear.

  1. Is the atom word value always the same, independent of the sequence modules are loaded into a runtime instance? If modules A and B both define/reference some atoms, will the value of the atom change from session to session, depending on whether A or B was loaded first?

  2. When matching for an atom inside a module, is there some "atom literal to atom value" resolution taking place? Do modules have some own module-local atom-value-lookup table, which gets filled in at load-time of a module?

  3. In a distributed scenario where 2 erlang runtime instances communicate with each other. Is there some "sync-atom-tables" action going on? Or do atoms get serialized as string literals, instead of as words?

2 Answers
Related