[m-dev.] Ordered conjunction
Erwan Jahier
Erwan.Jahier at irisa.fr
Fri Aug 25 05:49:39 AEST 2000
Ralph Becket <rbeck at microsoft.com> writes:
> 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).
What about `then'? It seems to me that it a degenerated case of
if-then-else where there is no `else' branch (or where the `else'
branch it equivalent to `fail').
> 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.
I agree. Moreover, I think it is more in the mercury spirit to make
explicit if a conjunction is commutative or not, the same way that
you must be explicit about the mode you have in mind when you define
a predicate/function.
> The current tension is that
> (1) writing code that really is order independent can get really
> obfuscated,
Well, when I say something like that, some people (actually, it
happened twice) argue that it is because I do not think (and program)
<<declaratively>>. What would you answer to that?
> (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
--
R1.
--------------------------------------------------------------------------
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