meta_predicate/1 declaration:- meta_predicate +MetaSpec
Provides for module name expansion of arguments in calls to the
predicate given by MetaSpec. All meta_predicate/1 declarations
must be at the beginning of a module.
functor(Arg1, Arg2,...)
Each Argn is one of:
:
:
+, -, ?, *
All meta_predicate
declarations must be at the beginning of a module, immediately after
the module declaration, because the meta_predicate declarations need to be
known at the time other modules are loaded if those modules use the
meta-predicates.
The reason for allowing a non-negative integer as an alternative to
: is that this may be used in the future to supply additional
information to the cross-referencer (library(xref)) and to the Prolog
compiler. An integer n is intended to mean that that that argument is
a term, which will be supplied n additional arguments.
Represents DEC-10 Prolog-style "mode" declaration. Provides for module name expansion of arguments in MetaSpec.
context_error
When a meta_predicate declaration is added,
removed or changed, the file containing it, as well as all the modules
that import the predicate given by MetaSpec, must be reloaded.
Consider a sort routine,
mysort/3, to which the name of the comparison predicate is passed as
an argument:
mysort(+CompareProc, +InputList, -OutputList)
If CompareProc is module sensitive, an appropriate meta_predicate
declaration for mysort/3 is:
:- meta_predicate mysort(:, +, -).
This means that whenever a goal mysort(A, B, C) appears in a
clause, it will be transformed at load time into mysort(M:A, B,
C), where M is the source module. The transformation will happen
unless
Many examples in library, e.g. library(samsort).
module/2
ref-mod-met