Next: The Foreign Include
Up: Foreign Language Interface
Previous: Using the library
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 types used in the
interface.
- term_t
-
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_t
-
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_t
-
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.
- predicate_t
-
Handle to a foreign predicate using with PL_call_predicate(). Predicates
live forever (although they can loose their definition).
- module_t
-
A module is a unique handle to a Prolog module. Modules are used only
to call predicates in a specific module.
- foreign_t
-
Return type for a C-function implementing a Prolog predicate.
- install_t
-
Type for the install()
and uninstall()
functions of shared
or dynamic link libraries. See section
.
Next: The Foreign Include
Up: Foreign Language Interface
Previous: Using the library
Passani Luca
Tue Nov 14 08:58:33 MET 1995