[mercury-users] single-solution context
fjh at cs.mu.OZ.AU
Tue Oct 13 00:33:34 AEST 1998
On 12-Oct-1998, Martin Stein <ms40 at inf.tu-dresden.de> wrote:
> I'm getting a software-error because there's something not implemented but I
> don't know exactly why. This somehow silly example should explain it:
> :- pred add(xx,xx,xx).
> :- mode add(in,in,out) is cc_nondet.
> :- mode add(in,in,out) is nondet.
> and somewhere in a goal
> Z1 = promise_only_solution(add(X,Y)),
> this yields:
> Software error: sorry, not implemented: taking address of pred
> `add/2' with multiple modes.
> (use an explicit lambda expression instead)
To elaborate on the parenthetical suggestion above,
in your example the higher-order term `add(X, Y)'
should be replaced with a lambda expression that specifies
which of the two modes you are taking the address of, i.e.
`(pred(Z::out) is cc_nondet :- add(X, Y, Z))'.
This requirement is mentioned in the "Creating higher-order terms"
section of the chapter on "Higher-order" in the Mercury Language
| If the predicate or function has more than one mode, you must use an
| explicit lambda expression to specify which mode you want.
The main reason for this restriction is to make it easier to implement;
that's why the compiler reports "sorry, not implemented: ..."
rather than "error: ...". However, it would certainly be better
for the compiler to issue a proper error message with line numbers
rather than reporting the problem via error/1.
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh> | of excellence is a lethal habit"
PGP: finger fjh at 126.96.36.199 | -- the last words of T. S. Garp.
More information about the users