At 07:15 PM 12/6/99 +0100, you wrote:
>Three cheers for Oliver! - he succeeded to circumvent the GC fault - which I
>was blind enough not to see.

That is wonderful, Ladislav.

What is not so wonderful is that your curry function - as I foretold in my
previous email from last night, indeed does do something unfortunate:

>> add: func [x y] [x + y]
>> addc: curry :add [x]
>> add5: addc 5
>> add5 5
== 10
>> add10: addc 10
>> add10 5
== 15
>> add5 5
== 15

add5 5 should continue to return 10, even if I've used addc 10 to create
add10 subsequently. It is due to the fact that your arguments are defined
in curry's context. If curry is reused, then x evaluates to a new value. 

If you check the curried function I posted yesterday, you will find that
that is one problem my version  - which you claimed does not work -
successfully solves.


Hope this helps,

Elan

>
>Ladislav
>
>-and I didn't succeed to copy the code in my last post, so again, now
>without a missing row:
>
> Rebol [
>    Title: "Curry"
>    Date: 6/12/1999
>    File: %curry.r
>    Version: 1.0.0
>    Author: ["Ladislav Mecir" "Oliver Schaefer" "Gabriele Santilli"]
>    Email: [[EMAIL PROTECTED] [EMAIL PROTECTED]  [EMAIL PROTECTED]]
>    ]
>
>curry: func ["Create curried functions" [catch]
>    fnc [any-function!] "Function to be curried"
>    args [block!] "Arguments of the curried fnc"
>    /local formargs restargs nonargs original
>    ][
>    formargs: first :fnc
>    if not empty? nonargs: difference/only args formargs [
>        throw make error! compose/deep [
>            script expect-set [(formargs)] [(nonargs)]
>            ]
>        ]
>    restargs: difference/only formargs args
>    original: append compose [(:fnc)] formargs
>    func args reduce ['func restargs original]
>    ]
>
>
>
>

Reply via email to