Re: Proposal: Lazy matching for local patterns

From: German Vidal <gvidal_at_dsic.upv.es>
Date: Wed, 24 Oct 2001 22:05:14 +0200 (CEST)

On Wed, 24 Oct 2001, Wolfgang Lux wrote:

> > Wolfang has given several examples where having accessor functions
> > flexible could be problematic (and I agree with him). However, if
> > I'm not wrong, having them always rigid we have that
>
> To be precise, the problem is not having flexible accessor functions
> but having both rigid *and* flexible accessor functions used in the
> same function. It will not cause any problems -- at least none which I
> can think of at the moment -- to have flexible accessor functions used
> in the expansion of one function and rigid functions for another
> function.
>
> > foo eval flex
> > foo (x,y) = x+y
> >
> > and
> >
> > foo eval flex
> > foo n = let (x,y) = n in x+y
> >
> > are different functions... Is this reasonable?
>
> IMHO, yes. In general both definitions give different functions. Just
> replace x+y by const x (const y 0) and you will see a difference
> between both function, namely for foo undefined.

Right (BTW, the arguments of const should be switched), with the lazy
lifting it is clear that function

  foo (x,y) = 1

is different from function

  foo n = let (x,y) = n in 1

However, this does not seem a very realistic situation, since
variables x and y are not used in the right-hand side (or their
evaluation is not required, as in your example).

When the evaluation of these variables is required, then I would
expect that both functions behave the same way. And this will not
happen if accessor functions are always rigid independently of the
evaluation annotation of the function where the local declaration
appears. For instance, if accessor functions are always rigid,
then "foo undefined" suspends with the definition

  foo eval flex
  foo n = let (x,y) in [x,y]

while it does not suspend with the definition

  foo eval flex
  foo (x,y) = [x,y]

Thus I would prefer that accessor functions have the same
evaluation annotation as the function where the local declaration
appear. Of course, I have no idea whether it is easy or difficult
to incorporate into existing compilers. Is there any special
trouble here?

Best,
German

---------------------------------------------------------
 German Vidal
 DSIC - UPV, Camino de Vera s/n, E-46022 Valencia, Spain
 gvidal_at_dsic.upv.es
 http://www.dsic.upv.es/~gvidal
--------------------------------------------------------

_______________________________________________
curry mailing list
curry_at_lists.RWTH-Aachen.DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/curry
Received on Do Okt 25 2001 - 08:45:42 CEST

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