[top] [up] [next]

Predicate indicators


Various built-in predicates of the Prolog language expect predicate indicators as an argument, a predicate indicator specifies which clauses must be manipulated. It consists of the name of the clause, the '/' operator and the arity of the clause.

For instance: test/2, this means, all clauses with the functor 'test' and two arguments.

Very often the same built-in predicate also accepts a predicate indicator sequence, for instance: [test/1, test/2, hi/0].

In the table below all possible exceptions that can be thrown while evaluating a predicate indicator are stated.

Exceptions  
A + 2 not the '/' operator so a type_error(predicate_indicator, Var) exception is thrown. Var is replaced by the expression A+2
the left operand of '/' is not an atom nor an instantiated variable a type_error(atom, Var) exception is thrown, Var is replaced by the left operand of '/'
the right operand of '/' is not an integer nor an expression that has an integer as result the type_error(integer, Var) exception is thrown, Var is replaced by the right operand of '/'
a negative integer as right operand of '/' a domain_error(not_less_than_zero, Var) exception is thrown, Var is replaced by the negative number
the arity number is larger than the maximum arity allowed a representation_error(max_arity) exception is thrown

[top] [up] [next]

 

info@trinc-prolog.com