[m-dev.] Adding default clauses to the language.

Ralph Becket rbeck at microsoft.com
Fri Aug 10 00:10:57 AEST 2001


> From: Ralph Becket [mailto:rbeck at microsoft.com]
> Sent: 09 August 2001 14:45
> 
> Could we borrow from the special case code for distinct modes
approach?
> 
> E.g.

[Holger and I seem to be thinking alike :) ]

> otherwise det_map3(F::in, Xs::in, Ys::in, Zs::in) = Result::out :-
> 	<body>.
> 
> This would support different otherwise clauses for each mode.

It may in fact be necessary to require that the otherwise/failing
clauses do indeed throw an exception.

For example, we want to avoid

:- pred p(int, int).
:- mode p(in, out) is det.
:- mode p(out, in) is det.

p(1, 101).
p(2, 102).
otherwise p(_::in, 103::out). %1%
otherwise p(3::out, _::in).   %2%

The two "natural" clauses plus %1% suggests that
p  =  {(1, 101), (2, 102)}  U  {(X, 103) | X \= 1, X \= 2}

whereas the two natural clauses plus %2% suggest that
p  =  {(1, 101), (2, 102)}  U  {(3, Y) | Y \= 101, Y \= 102}.

The two sets are not equivalent ((4, 103) is in the first, but
not the second; (3, 104) is in the second, but not the first),
violating p/2s det semantics (the mode lines declare p/2 to be
a bijection).

- Ralph
--------------------------------------------------------------------------
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