11.3.118 (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 should be at the beginning of a module.


callable, must be ground

Goal template or list of goal templates, of the form functor(Arg1, Arg2,...). Each Argn is one of:

requires module name expansion


in MetaSpec
“declaration appeared in query”


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:

  1. A has an explicit module prefix, or
  2. A is a variable and the same variable appears in the head of the clause in a module-name-expansion position.

See Also

Meta-Predicate Declarations, ref-mod-mne.

Send feedback on this subject.