next up previous contents
Next: List Processing Up: Programming Techniques and Previous: Evaluation in Prolog

Calling Patterns

For any given predicate with arity greater than 0, each argument may be intended to have one of three calling patterns:

For example, successor/2 above requires a calling pattern of
1st argument must be +

2nd argument can be + or - and is therefore ?

We write this as
 mode successor(+,?).

The notation used here is consistent with the mode declarations found in many Prolog libraries. For a further example, the mode declaration of is/2 is mode is(?,+).

Because of the discrepancy between the declarative and the procedural aspects of Prolog we often need to think carefully about the intended usage of a predicate. It is good practice to comment your code to indicate a predicate's intended usage.

Paul Brna
Mon May 24 20:14:48 BST 1999