Leopold Toetsch <[EMAIL PROTECTED]> writes:

> Piers Cawley <[EMAIL PROTECTED]> wrote:
>> Leopold Toetsch <[EMAIL PROTECTED]> writes:
>
>>> Klaas-Jan Stol <[EMAIL PROTECTED]> wrote:
>>>> Hello,
>>>
>>>> I've been playing with closures and subs but I have a little bit of
>>>> trouble with those.
>>>
>>>          newsub $P0, .Closure, _foo
>>>          $P0(q)
>>>          newsub $P0, .Closure, _foo
>>>          $P0(q)
>>>
>>> Closures have to be distinct.
>
>> Does this *really* mean that, if I create a closure in a function and
>> return it to my caller, that closure can only be invoked once?
>
> No, it can be invoked as often you like.
>
> But above case seems to be different and very similar to what I already
> asked:
>
>   (define (choose . all-choices)
>     (let ((old-fail fail))
>       (call-with-current-continuation
>
> You remember that snippet, it's now a test in t/op/gc.t. I had to insert
> the line below XXX and use a second closure, which has the "arr2" in it's
> context.
>
>      newsub choose, .Closure, _choose
>      x = choose(arr1)
>
>      # XXX need this these closures have different state
>      newsub choose, .Closure, _choose
>      y = choose(arr2)
>
> The question was, if that's technically correct.

Ah... of course, I was asking a stupid question. Always the most
plausible hypothesis I think. 

-- 
Piers 
Oh, predicting the future's easy, you just make a continuation at the
point you're asked, say anything and head off into the future to find what
happens, then take the continuation back to the question and give a more
accurate answer. -- me in #parrot

Reply via email to