[mercury-users] Mutually exclusive goals

Robert Bossy bossy at ccr.jussieu.fr
Thu Jul 8 00:33:07 AEST 1999


Hi everybody,

Sorry to push back to an old topic. The discussion was about declaring mutually exclusive goals. I'll be straight: I don't think it is a good idea yet. We must think about when we have mutual exclusion:

First we have:
(
 goal,
 ...
;
 not (goal),
 ...
)


This is obviously equivalent to 
(
 if goal then
 ...
else
 ...
)

It is supported by Mercury (I didn't tried the first way).


Then we have the switch:
(
 A = a,
 ...
;
 A = b,
 ...
;
 A = c,
 ...
)

Where a,b and c are constructors of a discrimminated union type.



Finally Rob suggested that A < B and A >= B would be mutually exclusive for integers. In that case, the mutual exclusion isn't something we say but something we prove... it is a consequence of the fact that integers are ordered.
So, if meaning is important, as I agree with Richard, then what we should declare is:
if A and B are expressions of an ordered type then A < B and A >= B are mutually exclusive goals.

My suggestion is to define a typeclass where there are two predicates equality('=') and order('<'). Then, the compiler would not interpret

(
 A < B
 ...
;
 A > B
 ...
;
 A = B
 ...
)

as nondet (it is even det!). Types such as int and float would be instances of that typeclass.


Now, not all mutually exclusive goals are a consequence of order. But we should think about what makes them live before directly declaring them.


Cordialement,
RB
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/users/attachments/19990707/8fe969ef/attachment.html>


More information about the users mailing list