The description of call/1 says:
call(:Goal)
Invoke Goal as a goal. Note that clauses may have variables as subclauses, which is identical to
call/1
.
I don't understand "clauses may have variables as subclauses".
Can anyone give an example?
Body conversion (7.6.2 Converting a term to the body of a clause) à la ISO core standard requires that variables directly inside control constructs inside a body of a clause are wrapped by call/1
.
Here is an example:
?- [user].
and(X,Y) :- X,Y.
^D
?- listing.
and(X,Y) :- call(X), call(Y).
The effect is that calling a !
has no effect, since the cut is confined inside call/1
.
This is seen here:
?- [user].
p(a).
p(b).
?- p(X), !.
X = a
?- and(p(X),!).
X = a ;
X = b
Edit 31.12.2019:
A Prolog system might want to add (*->)/2 (soft cut) to those control constructs whose arguments are converted thus amending 7.6.2.
7.6.2 Converting a term to the body of a clause
A term
T
can be converted to a goalG
which is the body of a clause:a)
If
T
is a variable thenG
is the control construct call (7.8.3), whose argument isT
.b)
If
T
is a term whose principal functor appears in table 9 thenG
is the corresponding control construct. If the principal functor ofT
iscall/1
orcatch/3
orthrow/1
then the arguments ofT
andG
are identical, else if the principal functor ofT
is(',')/2
or(;)/2
or(->)/2
then each argument ofT
shall also be converted to a goal.c)
If
T
is an atom or compound term whose principal functorFT
does not appear in table 9 thenG
is a predication whose predicate indicator isPT
, and the arguments, if any, ofT
andG
are identical.
And
7.8.3 call/1
call(G)
is true iffG
represents a goal which is true.When
G
contains!
as a subgoal, the effect of!
shall not extend outsideG
.
And
Table 9 on page 37: Principal functors and control constructs
(',')/2
goal arguments converted(;)/2
goal arguments converted(->)/2
goal arguments converted!/0
call/1
goal arguments not convertedtrue/0
fail/0
catch/3
goal arguments not convertedthrow/1