On 03/12/2012 10:32 AM, Wolfgang Lux wrote:
>> 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.
As it is mentioned in the comment of the PAKCS module SetFunctions,
this module provides a *prototypical* implementation of set functions.
Hence, if f is an n-ary function, (setn f) implements its set function.
It is not intended to use the setn operations in any other way
than applying them to defined operations. Thus, the expression
(set0 x) is not allowed since x is not a defined operation.
You are right that this restriction is currently not enforced by the
compiler (this would not be difficult but we like laziness...).
Hence, this library is intended to provide a simple implementation
to play with set functions. In a serious implementation, one should
add some notation in the language to denote the set function for
any defined operation. I am happy for any suggestion in this direction.
Best regards,
Michael
_______________________________________________
curry mailing list
curry_at_lists.RWTH-Aachen.DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/curry
Received on Mo Mär 12 2012 - 12:17:41 CET