[Next] [Up] [Previous] [Contents] [Index]
Next: Fetching arguments of Prolog Up: Calling C from Prolog Previous: Calling C from Prolog   Contents   Index

Term representation

A term is represented by a word containing 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 except when the term is an integer (in this case, the value represents the integer itself). The address points to a different location depending on the type of the term. The address in a reference points to the referenced term. An unbound variable is represented by a self-referencing pointer. The address in an atom points to the record for the atom symbol in the symbol table. The address in a structure [IMAGE png] 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. The address in a list [H|T] points to a block of two consecutive words where the first word stores the car H and the second word stores the cdr T.


[Next] [Up] [Previous] [Contents] [Index]
Next: Fetching arguments of Prolog Up: Calling C from Prolog Previous: Calling C from Prolog   Contents   Index
Neng-Fa Zhou () 2007-06-05