The "type of the term" is embedded in the term_t structure.
In file pl-fli.c
:
int PL_term_type(term_t t) { GET_LD word w = valHandle(t); int t0 = type_map[tag(w)]; switch(t0) { case PL_ATOM: ...
with the type_map
being an integer-to-integer mapping (i.e. tag to one of the PL_
values):
static const int type_map[8] = { PL_VARIABLE, PL_VARIABLE, /* attributed variable */ PL_FLOAT, PL_INTEGER, PL_STRING, PL_ATOM, PL_TERM, /* TAG_COMPOUND */ -1 /* TAG_REFERENCE */ };
The additional values PL_NIL, PL_BLOB, PL_RATIONAL, PL_LIST_PAIR, PL_DICT
are deduced by content inspection
and those values defined in SWI-Prolog.h
:
#define PL_VARIABLE (1) /* nothing */ #define PL_ATOM (2) /* const char * */ #define PL_INTEGER (3) /* int */ #define PL_RATIONAL (4) /* rational number */ #define PL_FLOAT (5) /* double */ #define PL_STRING (6) /* const char * */ #define PL_TERM (7) #define PL_NIL (8) /* The constant [] */ #define PL_BLOB (9) /* non-atom blob */ #define PL_LIST_PAIR (10) /* [_|_] term */