Difference between revisions of "Error e631: The predicate '%', which is declared as '%', is actually '%'"

From wiki.visual-prolog.com

(initial)
(No difference)

Revision as of 15:40, 11 June 2013

This error/warning says that the implementation of a predicate does not match it declaration with regards to Predicate Mode.

Consider this code

class predicates
    myPred : (integer X) -> integer Z.
clauses
    myPred(X) = Z :-
        Y = calculate(X),
        Y <> 0, % cannot divide by zero
        Z = 1/Y.

The predicate declaration does not state a predicate mode, so the predicate is a procedure. But if calculate returns 0 then the test Y <> 0 will fail, and then myPred will fail. However a procedure is not allowed to fail. This implementation of myPred can succeed or fail, so the implementation is determ. So in this case we will get the error:

e631: The predicate 'myPred/1->', which is declared as 'procedure', is actually 'determ'