[m-dev.] binding inst 'any' variables in if-then-else

Fergus Henderson fjh at cs.mu.OZ.AU
Mon Nov 14 11:09:42 AEDT 2005

I have a question about Ralph's recent change to make binding
any non-local variables with inst 'any' be inferred as 'impure'.

For an if-then-else, shouldn't it be OK to bind variables in the condition
if their only occurrences outside the condition are in the 'then' part?

For instance, consider the following example:

	:- mode solve(out) is nondet.
	solve(X) :-
		( constrain(Y), generate(Y) ->
			X = yes(Y)
			X = no

	:- mode constrain(free >> any) is semidet.
	:- mode generate(any >> ground) is nondet.

Currently the compiler rejects this, but I think it ought to be
allowed.  The rules for possibly binding variables with inst 'any'
should not be any more strict than the rules for binding variables
from free to ground.

Ralph, was that just an oversight, or is there some particular
reason why examples like that one are rejected?

Fergus Henderson                    |  "I have always known that the pursuit
                                    |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au

More information about the developers mailing list