Evaluable Predicates

This section describes (most of) the evaluable predicates provided by SB-Prolog. These can be divided into three classes: inline predicates, builtin predicates and library predicates.

Inline predicates represent ``primitive'' operations in the WAM. Calls to inline predicates are compiled into a sequence of WAM instructions in-line, i.e. without actually making a call to the predicate. Thus, for example, relational predicates (> /2, > = /2, etc.) compile to, essentially, a subtraction and a conditional branch. Inline predicates cannot be redefined by the user. Table [*] lists the SB-Prolog inline predicates.

Table: Inline Predicates of SB-Prolog
arg/3 =/2 < /2 = < /2
> = /2 > /2 / \ /2 ` \ /'/2
< </2 > >/2 =:=/2 = \  = /2
is/2 ?=/2 \  = \ /1
`_$builtin'/1 `_$call'/1 nonvar/1 var/1
integer/1 real/1 halt/0 true/0
fail/0


Unlike inline predicates, builtin predicates are implemented by C functions in the simulator, and accessed via the inline predicate `_$builtin'/1. Thus, if a builtin predicate foo/3 was defined as builtin number 38, there would be a definition in the system of the form

foo(X,Y,Z) :- '_$builtin'(38).

In effect, a builtin is simply a segment of code in a large case (i.e. switch) statement. Each builtin is identified internally by an integer, referred to as its ``builtin number'', associated with it. The code for a builtin with buitin number k corresponds to the k$\scriptstyle \em th$ case in the switch statement. SB-Prolog limits the total number of builtins to 256.

Builtins, unlike inline predicates, can be redefined by the user. For example, the predicate foo/3 above can be redefined simply by compiling the new definition into a directory such that during dynamic loading, the new definition would be encountered first and loaded.

A list of the builtins currently provided is listed in Appendix [*]. Appendix [*] describes the procedure to be followed in order to define new builtin predicates.

Like builtin predicates, library predicates may also be redefined by the user. The essential difference between builtin and library predicates is that whereas the former are coded into the simulator in C, the latter are written in Prolog.



Subsections