A 2. WG 17 resolves that call/2-N of 8.15.4 in N 208 shall require all implementations to support at least an arity of 8 (allowing seven extra arguments). The exact number shall be implementation dependent, with errors determined by the resulting call to a possibly non existent predicate.References refer to 13211-1:1995. Parts needing improvements are underlined.
TBD: control construct 7.8 vs. built-in 8.15 Logic and control.
NOTE — A built-in predicateapply/2is implemented in many existing processors. In most uses it can be directly replaced bycall/N. @@@
call(C, Arg1, ...) is true iff call(Goal) is
true where Goal is constructed by appending Arg1, ... additional
arguments to the arguments (if any) of C.
Thus, a goal
call(p(X1,...,XM), Y2, ...,
YN) is replaced by
call(p(X1, ..., XM, Y2, ...,
YN)).
call(+callable_term, ?term, ...)
C is a variableinstantiation error.
C is neither a variable nor a callable termtype_error(callable, C). (Remark: in other words C is a
number).
representation_error(max_arity).
call/9 is called. It is implementation dependent
whether or not this error is produced.existence_error(procedure,call/9).
NOTE — Due to the error in subclause d being implementation dependent (3.91), a conforming processor may implement call/N in one of the following ways.Implementation dependence also means that it is neither required nor forbidden to define the chosen approach in the processor documentation (5.4).
- 1) Implement only the seven built-in predicates
call/2up tocall/8.- 2) Implement
call/2..Nup to any N that is within8..max_arity (7.11.2.3)and produce existence errors for larger arities belowmax_arity.- 3) Implement
call/9and above only for certain execution modes.
call(integer, 3).
Succeeds.
call(functor(F,c), 0).
Succeeds, unifying F with c.
call(atom_concat(pro), log, Atom).
Succeeds, unifying Atom with prolog.
call(;, X = 1, Y = 2).
Succeeds, unifying X with 1. On backtracking,
it succeeds, unifying Y with 2.
call(;, (true->fail), X=1).
Fails.
The following examples assume that maplist/2
is defined with the following clauses:
maplist(_Cont, []).
maplist(Cont, [E|Es]) :-
call(Cont, E),
maplist(Cont, Es).
maplist(<(3), [1,2]).
Succeeds.
maplist(<(3), [1,2,3]).
Fails.
maplist(=(X), Xs).
Succeeds,
unifying Xs with [].
On re-execution, succeeds,
unifying Xs with [X].
On re-execution, succeeds,
unifying Xs with [X,X].
On re-execution, succeeds,
unifying Xs with [X,X,X].
Ad infinitum.