It is possible to register predicates and evaluable functions as special built-ins via the built-in special/3. A predicate indicator, the service class and the service number has to be specified. While registering the Prolog interpreter will automatically create an instance of the service class with the given service number parameter.Syntax:
directive --> "special(" indicator "," module "," integer ")".
:- special(foo/1, 'FooAPI', 7). % is a special predicate directive.
An evaluable function f/n is identified by the predicate property
sys_arithmetic/0 and a predi-cate indicator f/n+1. To ease the
end-user the Prolog system automatically implements for each
predicate bridging to an evaluable function, and for each
evaluable function tunnelling to a predicate.
X is p(Y1,..,Yn) :-
Z1 is Y1, .., Zn is Yn, p(Z1, .., Zn, X), !.
_ is p(_,..,_):-
f(Y1, .., Yn, X) :-
X is f(Y1,..,Yn).
During bridging the arguments are evaluated and then the
corresponding predicate is called with an additional last argument
for the result. If the corresponding predicate succeeds its choice
points are removed. If the predicate fails or if the result is not
a value, then an error is issued.
The bridging is further controlled by the virtual property of a predicate. If a predicate has this property the first argument Y1 gets special treatment. During bridging this argument will not be evaluated. This is useful for predicates that pass as the first argument the receiver object. The directive virtual/1 can be used to set the virtual property of a predicate.
The following special predicate predicates are provided:
The following predicate properties for special predicates are provided: