next up previous contents index
Next: Information about the State Up: Standard Predicates Previous: Comparison   Contents   Index


Meta-Predicates

call(#X)

If X is a nonvariable term in the program text, then it is executed exactly as if X appeared in the program text instead of call(X), e.g.
$\ldots$, p(a), call( (q(X), r(Y)) ), s(X), $\ldots$
is equivalent to
$\ldots$, p(a), q(X), r(Y), s(X), $\ldots$
However, if X is a variable in the program text, then if at runtime X is instantiated to a term which would be acceptable as the body of a clause, the goal call(X) is executed as if that term appeared textually in place of the call(X), except that any cut (`!') occurring in X will remove only those choice points in  X. If  X is not instantiated as described above, an error message is printed and call/1 fails.

Exceptions:

instantiation_error
Argument 1 of call/1 is not instantiated.
type_error
Argument 1 of call/1 is not a callable term.

#X

(where X is a variable) executes exactly the same as call(X). However, the explicit use of call/1 is considered better programming practice. The use of a top level variable subgoal elicits a warning from the compiler.

once(#X)

once/1 is defined as once(X):- call(X),!. once/1 should be used with care in tabled programs. The compiler can not determine whether a tabled predicate is called in the scope of once/1, and such a call may lead to runtime errors. If a tabled predicate may occur in the scope of once/1, use table_once/1 instead.

Exceptions: The same as call/1.

table_once(#X)

table_once/1 is a weaker form of once/1, suitable for situations in which a single solution is desired for a subcomputation that may involve a call to a tabled predicate. table_once(?Pred) succeeds only once even if there are many solutions to the subgoal Pred. However, it does not ``cut over'' the subcomputation started by the subgoal Pred, thereby ensuring the correct evaluation of tabled subgoals.


next up previous contents index
Next: Information about the State Up: Standard Predicates Previous: Comparison   Contents   Index
Baoqiu Cui
2000-04-23