[ Predicate Database and Compiler | Reference Manual | Alphabetic Index ]

# meta_predicate(++MetaSpecs)

Specifies the meta-arguments for the given predicates

MetaSpecs
  Callable term with meta-argument indicators, or a comma-separated list of such.

## Description

This declaration is normally used as a directive in compiled code, to specify if and how the arguments of a predicate refer to other predicates (meta-arguments). In ECLiPSe 6.1, this declaration does not affect the semantics of the program, and is only used by development tools like the cross-referencer or coverage analyser. In future releases, the compiler may make use of the information.

The meta-argument indicators describes the control flow through the arguments of a meta-predicate. The functor and arity of MetaSpec correspond to the functor and arity of the meta-predicate. The arguments are each populated with one of the following atomic descriptors:

    0

  A goal that is called as a subgoal of the declared predicate.

A positive integer

  A subgoal is constructed by appending the number of specified arguments, and then called.

    :-

  A clause (a fact or a rule).

    /

  A PredSpec of the form Name/Arity.

    :

  A module-sensitive argument, but none of the above.

    *

  An argument that is not one of the above.

Instead of the '*', which marks a non-meta argument, a mode indicator can be given. The effect is the same as specifying '*', and giving the mode in a separate mode/1 declaration:

    +

  The argument is instantiated, i.e. it is not a variable.

    ++

  The argument is ground, i.e. contains no variables.

    -

  The argument is not instantiated, it must be a free variable without any constraints or aliases.

    ?

  The mode is not known or it is neither of the above.

If one of the declared predicates does not exist, a local undefined predicate is created.

The declared meta-predicate information can be accessed by retrieving the predicate's 'meta_predicate' and 'mode' properties with get_flag/3.

### Modes and Determinism

- meta_predicate(++) is det

### Modules

This predicate is sensitive to its module context (tool predicate, see @/2).

### Exceptions

(4) instantiation fault
  MetaSpecs is not ground
(5) type error
  MetaSpecs is not a callable term, or a comma list of such
(6) out of range
  The callable term arguments are not meta-argument indicators

## Examples

    :- meta_predicate p(:,*,*).

    :- meta_predicate q(0,+,-).

    :- meta_predicate
    	maplist(2,*,*),
    	checklist(1,*).

## See Also

compile / 1, get_flag / 3, mode / 1, library(instrument), library(xref), library(coverage), library(lint)