Type tests are semi-deterministic predicates that succeed if the
argument satisfies the requested type. Type-test predicates have no
error condition and do not instantiate their argument. They have no
first-order “logical” interpretation; instead they inspect
the state of the computation at call time and are mainly used in clause
guards and assertions. See also library library(error),
must_be/2
and assertion/1.
var(X)
is true iff nonvar(X) fails.blob(dead) option of
read_term/3, Type
is the type the blob stands for, while
current_blob/2
reports its real type unavailable.<Type>(freed)
and every predicate that expects the real thing rejects it. Note that
only blobs can be released; an ordinary atom is reclaimed as a whole by
the atom garbage collector and remains valid for as long as it exists."hello".65In
traditional Prolog systems, double quoted text is often mapped to a list
of character codes. See also the Prolog flag
double_quotes.
atomic(Term) :-
nonvar(Term),
\+ compound(Term).
SWI-Prolog defines the following atomic datatypes: atom (atom/1),
string (string/1),
integer (integer/1),
floating point number (float/1),
rational (rational/1)
and blob (blob/2).
In addition, the symbol
[] (empty list) is atomic, but not an atom. See
section 5.1.
(22,true) are considered callable, but cause call/1
to raise a type error. Module-qualification of meta-argument (see meta_predicate/1)
using
:/2 causes callable to succeed on any
meta-argument.66We think that callable/1
should be deprecated and there should be two new predicates, one
performing a test for callable that is minimally module aware and
possibly consistent with type-checking in call/1
and a second predicate that tests for atom or compound.
Consider the program and query below:
:- meta_predicate p(0). p(G) :- callable(G), call(G). ?- p(22). ERROR: Type error: `callable' expected, found `22' ERROR: In: ERROR: [6] p(user:22)