• Places
    • Home
    • Graphs
    • Prefixes
  • Admin
    • Users
    • Settings
    • Plugins
    • Statistics
  • Repository
    • Load local file
    • Load from HTTP
    • Load from library
    • Remove triples
    • Clear repository
  • Query
    • YASGUI SPARQL Editor
    • Simple Form
    • SWISH Prolog shell
    • DSS Queries
  • Help
    • Documentation
    • Tutorial
    • Roadmap
    • HTTP Services
  • Login

6.4 Defining a meta-predicate
AllApplicationManualNameSummaryHelp

  • Documentation
    • Reference manual
      • Modules
        • Defining a meta-predicate
          • meta_predicate/1
    • Packages
Availability:built-in
meta_predicate +Head, ...
Define the predicates referenced by the comma-separated list Head as meta-predicates. Each argument of each head is a meta argument specifier. Defined specifiers are given below. Only 0..9, : and ^ are interpreted; the mode declarations +, - and ? are ignored.
0..9
The argument is a term that is used to reference a predicate with N more arguments than the given argument term. For example: call(0) or maplist(1, +).
:
The argument is module-sensitive, but does not directly refer to a predicate. For example: consult(:).
-
The argument is not module-sensitive and unbound on entry.
?
The argument is not module-sensitive and the mode is unspecified.
*
The argument is not module-sensitive and the mode is unspecified. The specification * is equivalent to ?. It is accepted for compatibility reasons. The predicate predicate_property/2 reports arguments declared using * with ?.
+
The argument is not module-sensitive and bound (i.e., nonvar) on entry.
^
This extension is used to denote the possibly ^-annotated goal of setof/3, bagof/3, aggregate/3 and aggregate/4. It is processed similar to `0', but leaving the ^/2 intact.
//
The argument is a DCG body. See phrase/3.

Each argument that is module-sensitive (i.e., marked 0..9, : or ^) is qualified with the context module of the caller if it is not already qualified. The implementation ensures that the argument is passed as <module>:<term>, where <module> is an atom denoting the name of a module and <term> itself is not a :/2 term where the first argument is an atom. Below is a simple declaration and a number of queries.

:- meta_predicate
        meta(0, +).

meta(Module:Term, _Arg) :-
        format('Module=~w, Term = ~q~n', [Module, Term]).
?- meta(test, x).
Module=user, Term = test
?- meta(m1:test, x).
Module=m1, Term = test
?- m2:meta(test, x).
Module=m2, Term = test
?- m1:meta(m2:test, x).
Module=m2, Term = test
?- meta(m1:m2:test, x).
Module=m2, Term = test
?- meta(m1:42:test, x).
Module=42, Term = test

The meta_predicate/1 declaration is the portable mechanism for defining meta-predicates and replaces the old SWI-Prolog specific mechanism provided by the deprecated predicates module_transparent/1, context_module/1 and strip_module/3. See also section 6.15.

ClioPatria (version V3.1.1-21-gb8003bb)