Re: Proposal: restrict multiple guards

From: Michael Hanus <mh_at_informatik.uni-kiel.de>
Date: Thu, 10 Apr 2003 17:42:52 +0200

Wolfgang Lux wrote:
> So this reminds me of another suggestion. I complained a while ago
> about the lack of some mechanism to match rules sequentially from
> top to bottom in Curry. My proposal to change the matching of rigid
> functions in this way or introduce another evaluation annotation for
> this purpose got a lot of disagreement on the list.

As far as I remember, there was a disagreement against the
idea to change the semantics of rigid functions in this way,
but there was an agreement that case expressions are a good replacement
for this.

> As I'm still convinced that this feature is useful, I have implemented
> case expressions in the Münster Curry compiler such that their
> alternatives
> are matched from top to bottom and (only) the first matching alternative
> is evaluated.
>
> What are your ideas wrt. to case expressions? Do you intend to provide
> some kind of top-down matching as in the Münster Curry compiler or will
> overlapping patterns in a case expression lead to non-deterministic
> evaluation?

Since we agreed that adding case expressions which provide
rigid top-down matching (without non-determinism) is useful
(also for default rules), this is exactly what I intend to add.
So, I guess it is compatible with the Münster Curry compiler.
However, I have no good idea for a simple formal description.
In order to keep the base language as it is, one could consider
the definition

swap z = case z of
           [x,y] -> [y,x]
           _ -> z

as syntactic sugar for the definition

swap eval rigid
swap [] = []
swap [x] = [x]
swap [x,y] = [y,x]
swap (x1:x2:x3:xs) = x1:x2:x3:xs

However, describing this transformation process in detail
is clumsy. Do you have a good suggestion?

Best regards,

Michael
Received on Do Apr 10 2003 - 17:42:52 CEST

This archive was generated by hypermail 2.3.0 : Do Jun 20 2024 - 07:15:06 CEST