YAP 7.1.0
Top-Level and Boot Predicates

Detailed Description


Class Documentation

◆ goal_expansion/3

class goal_expansion/3

goal_expansion( :G,+ M,- NG)

◆ goalexpansion/3

class goalexpansion/3

goalexpansion(+ G,+ M,- NG)

The goal_expansion/3 hook is an user-defined procedure that is called after term expansion when compiling or asserting goals for each sub-goal in a clause The first argument is bound to the goal and the second to the module under which the goal G will execute If goal_expansion/3 succeeds the new sub-goal NG will replace G and will be processed in the same way If goal_expansion/3 fails the system will use the default expandion mechanism

This hook is called:

  • at compilation time;
  • when running a query in the top-level

Older versions of YAP would call this procedure at every meta-call

◆ term_expansion/2

class term_expansion/2

term_expansion( T,- X)

user:term_expansion( T,- X)

This user-defined predicate is called by expand_term/3 to preprocess all terms read when consulting a file If it succeeds:

  • If X is of the form :- G or ?- G, it is processed as a directive
  • If X is of the form $source_location( File, Line): Clauseit is processed as if fromFileand lineLine`
  • If X is a list, all terms of the list are asserted or processed as directives
  • The term X is asserted instead of T

◆ message_hook/3

class message_hook/3

message_hook(+ Term, + Kind, + Lines)

Hook predicate that may be define in the module user to intercept messages from print_message/2 Term and Kind are the same as passed to print_message/2 Lines is a list of format statements as described with print_message_lines/3

This predicate should be defined dynamic and multifile to allow other modules defining clauses for it too

◆ exception/3

class exception/3

exception(+ Exception, + Context, - Action)

Dynamic predicate, normally not defined Called by the Prolog system on run-time exceptions that can be repaired just-in-time The values for Exception are described below See also catch/3 and throw/1 If this hook preodicate succeeds it must instantiate the Action argument to the atom fail to make the operation fail silently, retry to tell Prolog to retry the operation or error to make the system generate an exception The action retry only makes sense if this hook modified the environment such that the operation can now succeed without error

  • undefined_predicate Context is instantiated to a predicate-indicator ( Module:Name/Arity) If the predicate fails Prolog will generate an existence_error exception The hook is intended to implement alternatives to the SWI built-in autoloader, such as autoloading code from a database Do not use this hook to suppress existence errors on predicates See also unknown
  • undefined_global_variable Context is instantiated to the name of the missing global variable The hook must call nb_setval/2 or b_setval/2 before returning with the action retry