Of course, goal_expansion/2 is itself Prolog code.
Is it compiled first, without a prior application goal_expansion/2?
Very intriguing.
Can goal_expansion/2 by imported through a library?
Did you know ... | Search Documentation: |
Predicate goal_expansion/2 |
The predicate goal_expansion/2
is first called in the module that is being compiled, and then follows
the module inheritance path as defined by default_module/2,
i.e., by default user
and system
. If Goal
is of the form Module:Goal where Module
is instantiated, goal_expansion/2
is called on Goal using rules from module Module
followed by default modules for Module.
Only goals appearing in the body of clauses when reading a source file are expanded using this mechanism, and only if they appear literally in the clause, or as an argument to a defined meta-predicate that is annotated using‘0’(see meta_predicate/1). Other cases need a real predicate definition.
The expansion hook can use prolog_load_context/2 to obtain information about the context in which the goal is expanded such as the module, variable names or the encapsulating term.
Of course, goal_expansion/2 is itself Prolog code.
Is it compiled first, without a prior application goal_expansion/2?
Very intriguing.
Can goal_expansion/2 by imported through a library?