:- meta_predicate +MetaSpec
Provides for module name expansion of arguments in calls to the
predicate given by MetaSpec. All
should be at the beginning of a module.
callable, must be ground
Goal template or list of goal templates, of the form
Each Argn is one of:
requires module name expansion
If the argument will be treated as a goal then it is better to explicitly indicate this using an integer, see the next item.
a non-negative integer.
This is a special case of ‘:’ that means that the argument can be
made into a goal by adding nsuppressed additional
arguments. E.g., if the argument will be passed to
0 (zero) should be used.
As another example, the meta_predicate declaration for the built-in
call/3 would be
:- meta_predicate call(2,?,?), since
call/3 will add two arguments to its first argument in order to
to construct the goal to invoke.
An integer is treated the same as ‘:’ above by the SICStus runtime. Other tools, such as the cross referencer (see The Cross-Referencer) and the SICStus Prolog IDE (see SICStus Prolog IDE), will use this information to better follow predicate references in analyzed source code.
Exceptions in the context of loading code are printed as error messages.
MetaSpec not ground.
MetaSpec not a valid specification.
Declaration appeared in a goal.
Declaration appeared as a clause.
Consider a sort routine,
mysort/3, to which the name of the comparison predicate is passed as
mysort(LessThanOrEqual, InputList, OutputList) :- … %% LessThanOrEqual is called exactly like the built-in @=</2 ( call(LessThanOrEqual, Term1, Term2) -> … ; … ), …
meta_predicate declaration for
:- meta_predicate mysort(2, +, -).
since the first argument, LessThanOrEqual, will have two
additional arguments added to it (by
call/3) when invoked.
This means that whenever a goal
C) appears in a clause, it will be transformed at load time
mysort(M:A, B, C), where M
is the source module. The transformation will happen unless:
Meta-Predicate Declarations, ref-mod-mne.