Re: Proposal: Change semantics of pattern matching

From: Michael Hanus <mh_at_informatik.uni-kiel.de>
Date: Tue, 26 Sep 2000 18:23:15 +0200 (MEST)

Wolfgang Lux wrote:
> Proposal:
> =========
> In a rigid function, only the first matching rule should be evaluated,
> where rules are evaluated from top to bottom.
>
> In order to write a rigid function with the current semantics, i.e.,
> where all rules with matching left hand sides are non-deterministically
> applied, the function must be annotated explicitly with
>
> eval f nondet
>
> Rationale:
> ==========
> IMHO, Curry's most annoying "feature" is that all patterns on the left
> hand side of a function's rules must be non-overlapping in order to
> write a deterministic (rigid) function. This is annoying (and

I agree that this could be annoying (in particular, since we
have a module for Okasaki's red-black trees), but on the other
hand, the proposed change has important consequences on the
declarative flavor of Curry. In Curry, each equation defining
a function has a true equational meaning: each subterm
matching the left-hand side is replacable by the right-hand side.
In Haskell, which has the proposed matching behavior, one could
have a program containing

  ....
  f x = 2

but the evaluation of (f 0) might return just 1 depending on
rules written above, i.e., rules have no longer a "local"
meaning by its own. However, I think that compositionality is important,
i.e., the meaning of a function should be composed by its
individual rules. If this is not the case, this should
be clearly marked. I feel that an eval annotation is not
enough since the other kind of eval annotations only
influence the operational but not the declarative meaning
of functions. To overcome this annoying situation,
I would prefer to annotate the individual rules to make
it explicit that this rule has not an equational meaning,
for instance like in Juanjo's proposal for default rules as

  ...
  default f x = 2

Although this does not solve all problems (e.g., nested
default rules), I am very much in favor to think in this
direction to keep the declarative nature of Curry.

Best regards,

Michael

_______________________________________________
curry mailing list
curry_at_lists.RWTH-Aachen.DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/curry
Received on Di Sep 26 2000 - 18:33:06 CEST

This archive was generated by hypermail 2.3.0 : Do Feb 01 2024 - 07:15:05 CET