Prolog Language Coding guidelines Order of arguments


Example

Ideally, Prolog predicates can be used in all directions. For many pure predicates, this is also actually the case. However, some predicates only work in particular modes, which means instantiation patterns of their arguments.

By convention, the most common argument order for such predicates is:

  • input arguments are placed first. These arguments must be instantiated before the predicate is called.
  • pairs of arguments that belong together are placed adjacently, such as p(..., State0, State, ...)
  • intended output arguments are placed last. These predicates are instantiated by the predicate.