![]() |
YAP 7.1.0
|
A predicate in a module is said to be undefined if there are no clauses defining the predicate, and if the predicate has not been declared to be dynamic. More...
A predicate in a module is said to be undefined if there are no clauses defining the predicate, and if the predicate has not been declared to be dynamic.
What YAP does when trying to execute undefined predicates can be specified in three different ways:
user:unknown_predicate_handler/3
This solution is compatible with SICStus Prologclass unknown_predicate_handler/3 |
unknown_predicate_handler(+ Call, + M, - N)
In YAP, the default action on undefined predicates is to output an error
message Alternatives are to silently fail
, or to print a warning
message and then fail This follows the ISO Prolog standard where the default action is error
The user:unknown_predicate_handler/3 hook was first introduced in SICStus Prolog It allows redefining the answer for specifici calls As an example after defining undefined/1
by:
and executing the goal:
a call to a predicate for which no clauses were defined will result in the output of a message of the form:
followed by the failure of that call
class unknown/2 |
no need for code at this point
%'$undef_error'(fail,_) :- %% fail
unknown(- O,+ N)
The unknown predicate, informs about what the user wants to be done when there are no clauses for a predicate Using unknown/3 is strongly deprecated We recommend setting the unknown
prolog flag for generic behaviour, and calling the hook user:unknown_predicate_handler/3 to fine-tune specific cases undefined goals