There are two sorts of objects that Prolog may want to handle: atomic and compound. Atomic objects include numbers and atoms, and compound objects include data structures and arrays. To be more precise about it, an atomic type is defined by one of the following. A long integer is 64 bits on DEC Alpha platforms and 32 bits on other Quintus Prolog platforms. Long integers are however truncated to 32 bits (sign-extended) by the Prolog system:
long
integer
short
char
unsigned_long
unsigned_integer
unsigned_short
unsigned_char
float
double
atom
string
address
pointer(_)
, but structs
does no type checking for you. Represented as a Prolog integer.
opaque
And compound types are defined by one of:
pointer
(Type)
array
(Num,Type)
array(
Type)
struct(
Fields)
union(
Members)
C programmers will recognize that the kinds of data supported by this package were designed for the C language. They should also work for other languages, but programmers must determine the proper type declarations in those languages. The table above makes clear the storage requirements and interpretation of each type.
Note that there is one important difference between the structs
package
and C: the structs
package permits declarations of pointers to arrays.
A pointer to an array is distinguished from a pointer to a single
element. For example
pointer(array(char))
is probably a more appropriate declaration of a C string type than
pointer(char)
which is the orthodox way to declare a string in C. Note that the
structs_to_c
tool described below does generate proper (identical)
C declarations for both of these structs
declarations.