Interface Data types

The interface functions can be divided into two groups. The first group are functions to obtain data from Prolog or pass data to Prolog. These functions use Prolog internal data types. The second group consists of type conversion functions convert between Prolog internal data and C primitive types. Below is a description of the Prolog data types used in the interface.

term
Terms represent arbitrary Prolog data (variables, atoms, integers, floats and compound terms). Terms live either until backtracking takes us back to a point before the term was created or the garbage collector has collected the term.
atomic
Atomics are Prologs primitive data types (integers, atoms and floats). They can be transformed to C data types (int, char * resp. double). The Prolog representation for an integer is a tagged version of that integer. The mapping between C ints and Prolog integers can only be different over different releases of SWI-Prolog. Atoms are represented by a pointer to a data structure on the Prolog heap. Each such data structure is a unique representation of a string (e.g. to verify that two atoms represent the same string comparing the atoms suffices). The mapping between atoms and string are likely to vary over different sessions of Prolog. Floats are represented as (tagged) pointers to a float living on the global stack. For their life time the same rules apply as for terms. Whether two floats represent the same number can only be discovered by transforming both to C floats and then comparing them. Strings are represented as a tagged pointer to a char * on the global stack or heap. The rules for their lifetime and comparison equal those for floats and terms.
functor
A functor is the internal representation of a name/arity pair. They are used to find the name and arity of a compound term as well as to construct new compound terms. Like atoms they live for the whole Prolog session and are unique.
module
A module is a unique handle to a Prolog module. Modules are used only to call predicates in a specific module.