mercury and determinism

Henk Vandecasteele henkv at
Wed Feb 19 20:56:53 AEDT 1997

Any particular reason for the following:

:- module little.
:- interface.
:- type t.
:- pred p(t,t).
:- mode p(in, out) is det.
:- pred q(t,t).
:- mode q(in, out) is det.
:- implementation.
:- import_module int.

:- type t ---> a;b(int).

p(X, Y):-
	(X=a, Y=b(0);
	 X=b(N), N1 is N +5, Y=b(N1)

q(X, Y):-
	( X = a -> Y=b(0);
	  X = b(N), N1 is N + 5, Y = b(N1)


$ mc little.m
little.m:007: In `q(in, out)':
little.m:007:   error: determinism declaration not satisfied.
little.m:007:   Declared `det', inferred `semidet'.
little.m:021:   Unification of `X' and `b(N)' can fail.
For more information, try recompiling with `-E'.

Because I'd like to reuse my code in Prolog, I prefer the definition of
q above the one of p. There could be some serious efficiency-problems
in some Prolog-implementations  with the first one.


More information about the users mailing list