Mode Annotations

The mode annotations are useful to tell whether an argument is input or output or both. They also describe formally the instantiation pattern to the call that makes the call to the built-ins determinate.

The mode annotations in the above example are + and -. Following is a complete description of the mode annotations you will find in the reference pages:


+
Input argument. This argument will be inspected by the predicate, and affects the behavior of the predicate, but will not be further instantiated by the predicate. An exception is raised if the argument isn't of the expected type. Note that the type class of an input arguments might include var.
-
Determinate output argument. This argument is unified with the output value of the predicate. An output argument is only tested to be of the same type as the possible output value, if the type is simple (see mpg-ref-aty-sim), and such testing is helpful to the user. Given the input arguments, the value of a determinate output argument is uniquely defined.
*
Nondeterminate output argument. This argument is unified with the output value of the predicate. An output argument is only tested to be of the same type as the possible output value, if the type is simple (see mpg-ref-aty-sim), and such testing is helpful to the user. The predicate might be resatisfiable, and might through backtracking generate more than one output value for this argument.
+-
An input argument that determinately might be further instantiated by the predicate. Since it is an input argument, an exception will be raised if it isn't in the expected domain.
+*
An input argument that might be further instantiated by the predicate. The predicate might be resatisfiable, and might through backtracking generate more than one instantiation pattern for this argument. Since it is an input argument, an exception will be raised if it isn't in the expected domain.

If the synopsis of a predicate has more than one mode declaration, the first (the topmost) that satisfies both modes and types (of a goal instance), is the one to be applied (to that goal instance).

All built-in predicates of arity zero are determinate (with the exception of repeat/0).

For input arguments, an exception will be raised if the argument isn't of the specified type.

For output arguments, an exception might be raised if the argument is nonvar, and not of the specified type. The generated value of the argument will be of the specified type.