Re: set functions and weak encapsulation

From: Sebastian Fischer <sebf_at_informatik.uni-kiel.de>
Date: Mon, 12 Mar 2012 10:57:58 +0100

> Even if this were possible (in MCC it wouldn't work at present), it would look like a bad idea to me because that would make code using your proposed values function very fragile under program transformations.

More than with 'findall' in the current MCC? There we also have

    findall (\y -> (0?1) =:= y) = [0,1]

but

    let x = 0?1 in findall (\y -> x =:= y) = [0] ? [1]

which looks just as fragile under program transformations. The
difference is that in this case the example differ according to
sharing under a lambda which one might argue (and you probably do) is
an important difference.

>> Or can you give an example, where evaluation order determines the
>> result of a program using set functions (as implemented in PAKCS)?
>
> Sure. Just consider a slightly adapted version of an example from [1]:
>  let x = 0?1 in sortValues (set0 x) ++ [x] ++ sortValues (set0 x)
> The result is [0,1,0,0] ? [0,1,1,1] which clearly shows that the result of sortValues (set0 x) depends on whether it is evaluated before or after x is evaluated to (head) normal form. And you can easily construct similar examples with other functions from the module's interface like minValue, valueOf, etc.

Ah interesting. It was not clear to me that the SetFunctions module in
PAKCS provides more power than set functions as described in the paper
[2]. Your use of 'set0 x' for a *variable* 'x' would not be possible
under the set functions proposal, where set functions only exist for
top-level declarations.

Sebastian

[2] Sergio Antou and Michael Hanus, Set Functions for Functional Logic
Programming (PPDP'09)

_______________________________________________
curry mailing list
curry_at_lists.RWTH-Aachen.DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/curry
Received on Mo Mär 12 2012 - 11:50:14 CET

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