Some predicates take goals as arguments (i.e.
meta-predicates). These arguments must include a
module specification stating which module the goal
refers. Some other predicates also need module information
compile/1. The property of needing module
information is declared with a meta-predicate declaration
(see Meta Decl). Goals for these predicates are
module name expanded to ensure the module information.
Goals appearing in queries and meta-calls are expanded
prior to execution while goals in the bodies of clauses and
directives are expanded at compile time. The expansion is
made by preceding the relevant argument with `Module:'.
If the goal is prefixed by `Module:', Module is
used for the expansion; otherwise, the source/type-in module is
used. An argument is not expanded if:
| ?- [user]. | :- meta_predicate p(:), q(:). | r(X) :- p(X). | q(X) :- p(X). | ^D % consulted user in module user, 0 msec 424 bytes | ?- listing. r(A) :- p(user:A). q(A) :- p(A).
q/1 are declared as meta-predicates
r/1 is not. Thus the clause
r(X) :- p(X) will
be transformed to
r(X) :- p(M
:X), by item 2 above, where
M is the type-in module, whereas
q(X) :- p(X) will
| ?- m:assert(f(1)).
assert/1 is called in the module
this does not ensure that
f(1) is asserted into
assert/1 is a meta-predicate makes the system
module name expand the goal, transforming it to
m:assert(m:f(1)) before execution. This way,
supplied the correct module information.