An atom is an Elixir named constant. Its text is stored in the runtime atom table, while the value holds a reference to that text, keeping comparisons fast, memory use low, and code readable. section 2.4.2
Atoms support several language-level roles:
- Write ordinary constants with a colon, such as :an_atom, or quote names containing spaces. section 2.4.2
- Use uppercase names as aliases; the compiler transforms AnAtom into the atom :"Elixir.AnAtom". section 2.4.2
- Represent booleans with true and false atoms, use nil as the null value, and use module names as atoms at runtime. section 2.4.2 section 2.7.1
iex(1)> AnAtom == :"Elixir.AnAtom" true
Verify that an uppercase alias and its fully qualified atom are identical. section 2.4.2
iex(1)> true and false false iex(2)> false or true true iex(3)> not false true iex(4)> not :an_atom_other_than_true_or_false ** (ArgumentError) argument error
Observe boolean operators accepting true and false while rejecting unrelated atoms with not. section 2.4.2
