[m-dev.] Adding default clauses to the language.
Ralph Becket
rbeck at microsoft.com
Thu Aug 9 19:21:22 AEST 2001
Ah well, it would have been nice had it been workable :)
Could some approximation be useful with, say, some mechanism
for throwing exceptions for cases that aren't covered,
regardless of mode?
E.g.
:- func (func(T1, T2, T3) = T, list(T1), list(T2), list(T3)) = list(T)
is promised_det.
^^^^^^^^^^^^
det_map3(_, [], [], [] ) = [].
det_map3(F, [X | Xs], [Y | Ys], [Z | Zs]) =
[F(X, Y, Z) | det_map3(F, Xs, Ys, Zs)].
where promised_det is the same as det, except that an exception is
raised should the function fail (i.e. it converts a semidet definition
into one that is det.) Does moving the new syntax into the mode
declaration do us any good?
This doesn't provide the ability to have a non-exception throwing
catch-all mechanism, but does handle the common "this really should be
exhaustive; throw an exception if I'm wrong" situation.
You see often partial pattern matchings in Haskell & ML code, and they
are clearer for not having to explicitly list the exception cases.
- 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