12.4.3.1 Testing the type of a term
AllApplicationManualNameSummaryHelp

  • Documentation
    • Reference manual
      • Foreign Language Interface
        • The Foreign Include File
          • Analysing Terms via the Foreign Interface
            • Testing the type of a term
              • PL_term_type()
              • PL_is_variable()
              • PL_is_ground()
              • PL_is_atom()
              • PL_is_string()
              • PL_is_integer()
              • PL_is_rational()
              • PL_is_float()
              • PL_is_callable()
              • PL_is_compound()
              • PL_is_functor()
              • PL_is_list()
              • PL_is_pair()
              • PL_is_dict()
              • PL_is_atomic()
              • PL_is_number()
              • PL_is_acyclic()
    • Packages
Availability:C-language interface function
int PL_term_type(term_t)
Obtain the type of a term, which should be a term returned by one of the other interface predicates or passed as an argument. The function returns the type of the Prolog term. The type identifiers are listed below. Note that the extraction functions PL_get_*() also validate the type and thus the two sections below are equivalent.
        if ( PL_is_atom(t) )
        { char *s;

          PL_get_atom_chars(t, &s);
          ...;
        }

or

        char *s;
        if ( PL_get_atom_chars(t, &s) )
        { ...;
        }

VersionĀ 7 added PL_NIL, PL_BLOB, PL_LIST_PAIR and PL_DICT. Older versions classify PL_NIL and PL_BLOB as PL_ATOM, PL_LIST_PAIR as PL_TERM and do not have dicts.

PL_VARIABLE A variable or attributed variable
PL_ATOM A Prolog atom
PL_NIL The constant []
PL_BLOB A blob (see section 12.4.9.2)
PL_STRING A string (see section 5.2)
PL_INTEGER A integer
PL_RATIONAL A rational number
PL_FLOAT A floating point number
PL_TERM A compound term
PL_LIST_PAIR A list cell ([H|T])
PL_DICT A dict (see section 5.4))