head 1.2; access; symbols; locks ulrich:1.2; strict; comment @# @; 1.2 date 2010.07.17.09.57.34; author ulrich; state Exp; branches; next 1.1; 1.1 date 2009.10.19.17.48.50; author ulrich; state Exp; branches; next ; desc @@ 1.2 log @Changes at ICLP @ text @ call/N

call/N.

Ulrich Neumerkel 2009-09-20 (Version history)
This draft is based on Paulo Moura's draft core 8.15.4 N208 13211-1:2006 of 2008-11-17. It is being prepared for the second technical corrigendum of 13211-1:1995 and incorporates the following resolution of Pasadena, 2009.
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.

8.15.4 call/2..8

NOTE — A built-in predicate apply/2 is implemented in many existing processors. In most uses it can be directly replaced by call/N. @@@@@@

8.15.4.1 Description

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)).

8.15.4.2 Template and modes

call(+callable_term, ?term, ...)

8.15.4.3 Errors

a) C is a variable
instantiation error.
b) C is neither a variable nor a callable term
type_error(callable, C). (Remark: in other words C is a number).
c) The number of arguments in the resulting goal exceeds the implementation defined maximum arity (7.11.2.3)
representation_error(max_arity).
d) 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.
1) Implement the minimum, which are the seven built-in predicates call/2 up to call/8.
2) Implement call/2..N up to any N that is within 8..max_arity (7.11.2.3) and produce existence errors for larger arities below max_arity.
3) Implement call/9 and above only for certain execution modes.
Implementation dependence also means that it is neither required nor forbidden to define the chosen approach in the processor documentation (5.4).

8.15.4.4 Examples

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 and Y with 2.

call(;, (true->fail), X=1).
   Fails.

Validated HTML @ 1.1 log @Initial revision @ text @d75 1 a75 1 8.15.4 13211-1:2006 of 2008-11-17. It d90 2 d106 7 d124 3 a126 4
b) C is neither a variable nor a callable term
type_error(callable, C).
(Remark: a and b may not be needed, maybe call(1, 2) should rather produce a type error, similar to (=..)/2. d139 1 a139 1 NOTE — Due to the error in clause d being implementation a172 1 d174 2 d177 3 a179 2 The ability to pass compound terms to call/N in Prolog is the equivalent of closures in LISP. a181 1 call(p(X1,...,Xm), Y1, ..., Yn) :- p(X1, ..., Xm, Y1, ..., Yn). @