Term representation

A term is represented by a word that contains a value and a tag. The tag distinguishes the type of the term. Floating-point numbers are represented as special structures in the form of $float(I1,I2,I3), where I1, I2, and I3 are integers.

The value of a term is an address, unless the term is an integer. If the term is an integer, the value represents the integer itself. The address points to a location that depends on the type of the term. For a reference, the address points to the referenced term. An unbound variable is represented by a self-referencing pointer. For an atom, the address points to the record for the atom symbol in the symbol table. For a structure, $f(t_1,\ldots,t_n)$, the address points to a block of n+1 consecutive words, where the first word points to the record for the functor f/n in the symbol table, and the remaining n words store the components of the structure. For a list, [H|T], the address points to a block of two consecutive words, where the first word stores the car, H, and the second word stores the cdr, T.

Neng-Fa Zhou 2013-01-25