Clause
← All documentation

Term representations

Admitted kinds: atoms/booleans, arbitrary integers, finite binary64 floats, tuples, proper/improper lists and strings, maps, bitstrings and ordinary tuple records; native records (native records); funs (function values); local pids, ports and references (below, ports). Word encodings are in abi.md.

Ownership

Atoms

Integers

Floats

Tuples, lists, strings

Maps

Bitstrings

Records

Pids and references

Plan 11 step 42. self/0 returns the calling process's pid, make_ref/0 a new reference; pid_to_list/1 and ref_to_list/1 return their text.

Comparison and order

Iterative with no work cap, as in OTP: only memory for pending pairs bounds a comparison, map key searches included, and identical words are equal without a walk. Byte-aligned bitstrings compare whole bytes at once. Order: numbers < atoms < references < funs < pids < tuples < native records < maps < nil < lists < bitstrings (funs order among themselves). Atoms compare by UTF-8 spelling (code-point order); tuples by arity then fields; maps by size, then keys, then values; bitstrings by logical bits.

Printing

format_term (output.hpp) renders any admitted term in one of two OTP styles. Integers, tuples (records are tuples) and nesting look the same in both.

~w (TermStyle::write)erlang:display/1 (TermStyle::display)
AtomsQuoted unless a Latin-1 lowercase letter starts it and name characters (with @) follow; reserved words and maybe/else are quoted; beyond Latin-1 escapes as \x{H}Quoted unless a Latin-1 lowercase letter starts it and alphanumerics or _ follow; reserved words and @ get no special rule; UTF-8 kept
FloatsShortest round trip in OTP layout: 0.1, 100.0, 1.0e16, 1.5e-7C %.6e: 1.500000e+00
ListsElements: [104,105], [1,2|3]A flat list of printable Latin-1 bytes prints as "hi" (raw bytes; only \n and " escaped)
Bitstrings<<1,2,5:3>>A printable ASCII binary prints as <<"hi">>, others as ~w
Maps#{k => v,k2 => v2}#{k=>v,k2=>v2}