Mode Declarations

## 6.6 Mode Declarations

Mode declarations are a way for the user to give some additional information to the compiler, thus enabling it to do a better job. The ECLiPSe compiler makes use of the mode information mainly to improve indexing and to reduce code size.
Mode declarations are optional. They specify the argument instantiation patterns that a predicate will be called with at runtime, for example:

>     :- mode p(+), q(-), r(++, ?).

The possible argument modes and their meaning are:

+
  - The argument is instantiated, i.e. it is not a variable.
++
  - The argument is ground.
−
  - The argument is not instantiated, it must be a free variable without any constraints, especially it must not occur in any other argument and it cannot be a suspending variable.
?
  - The mode is not known or it is neither of the above ones.

Note that, if the actual instantiation of a predicate call violates its mode declaration, the behaviour is undefined. Usually, an unexpected failure occurs in this case.