Re: slight differences between non-termination and failure

From: Sebastian Fischer <sebf_at_informatik.uni-kiel.de>
Date: Thu, 03 Feb 2011 18:35:21 +0900

On Thu, Feb 3, 2011 at 6:11 PM, Jan Christiansen <jac_at_informatik.uni-kiel.de
> wrote:

> On 03.02.2011, at 09:16, Michael Hanus wrote:
>
>> Right, otherwise I would be surprised since purely functional Curry
>> programs (without overlapping rules) should have the same operational
>> behavior as in Haskell.
>>
>
> Well, I think at least this is not the case if you consider rule based
> definitions.


Yes, sometimes Curry programs are lazier than Haskell programs because Curry
evaluates expressions only when needed. It would be possible to add more
examples of this kind by interpreting the pattern of an operation defined by
a single rule always as lazy. This is useful if the pattern is used as a
selector like in

    aPairWithSwappedElements (x,y) = (y,x)

but counter productive if the pattern is used as a test like in

    onlyTrueIfTheArgumentIsAlsoTrue True = True

so it's probably not a good idea. If the pattern is used both as a test and
a selector as in

    aListWhereTheFirstElementIsDuplicated (x:xs) = x:x:xs

it is questionable whether the pattern should be interpreted as lazy.

I think it could be interpreted as lazy if it is statically known that it
cannot fail (like in my examples which would all three behave the same after
such a change).

Sebastian



_______________________________________________
curry mailing list
curry_at_lists.RWTH-Aachen.DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/curry
Received on Do Feb 03 2011 - 13:37:47 CET

This archive was generated by hypermail 2.3.0 : Do Mär 28 2024 - 07:15:11 CET