10.8 Internal Representation of Records

Record expressions are translated to tuple expressions during compilation. A record defined as:

  1. -record(Name, {Field1,...,FieldN}).

is internally represented by the tuple:

  1. {Name,Value1,...,ValueN}

Here each ValueI is the default value for FieldI.

To each module using records, a pseudo function is added during compilation to obtain information about records:

  1. record_info(fields, Record) -> [Field]
  2. record_info(size, Record) -> Size

Size is the size of the tuple representation, that is, one more than the number of fields.

In addition, #Record.Name returns the index in the tuple representation of Name of the record Record.

Name must be an atom.