[m-dev.] Ordered conjunction

Ralph Becket rbeck at microsoft.com
Fri Aug 25 02:33:07 AEST 2000


I know this has come up before, but I just want to restate the case
for an ordered conjunction (P && Q) which constrains the compiler to
call P before Q (for && pick the symbol of your choice).

This allows one to write code like

:- pred num_in_rg(int::in, int::out, int::in) is nondet.

num_in_rg(Lo, N, Hi) :-
	Lo =< Hi &&
	( N = Lo ; num_in_rg(Lo + 1, N, Hi) ).

safely.  If the && is an ordinary, unordered conjunction then
the subgoals might get rearranged and this predicate could
fail to terminate.

The current tension is that
(1) writing code that really is order independent can get really
obfuscated,
(2) so one usually goes for `pretty' code and hopes for the best
(accepting the appropriate guilt burden).

Would this be easy to add to the language?  If so, does anyone with
the right skill set have the time?

It's probably not a high priority thing, but I reckon it's a wart
that should be fixed for 1.0.

Ralph

--
Ralph Becket      |      MSR Cambridge      |      rbeck at microsoft.com 
--------------------------------------------------------------------------
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