Thanks,
klaas-jan
.sub some_global_coroutine
.yield(1)
.yield(2)
.yield(3)
.yield(4)
.yield(5)
.end
.local pmc mycoro
# create the coroutine
mycoro = global 'some_global_coroutine'
mycoro = clonoe mycoro
.local pmc corresult
# call it a few times
corresult = mycoro() # 1
corresult = mycoro() # 2
corresult = mycoro() # 3
mycoro."reset"() # reset the coroutine
corresult = mycoro() # 1 again (not 4)
But maybe this was already possible, I don't know. I'm not familiar with the
implementation specifics of a Coroutine, but it seems to me it shouldn't be
too hard.
Kind regards,
klaas-jan
On 5/29/06, Elizabeth Mattijsen <l...@dijkmat.nl> wrote:
> Good point.
>
> Essentially you would be removing the continuation context of that
> subroutine / method.
>
> A method on a method maybe?
>
> foo.reset( bar => 1 );
>
> comes to mind?
>
>
> Suggestions? Comments?
>
>
> Liz
>
Good point.
> mycoro."reset"() # reset the coroutine
> corresult = mycoro() # 1 again (not 4)
>
> But maybe this was already possible, I don't know.
Not yet. But it should be simple and straightforward to implement it.
During the first invoke() the coroutine is allocating its context stuff
(co->ctx, ctx->lex_pad, ctx->current_cont). .reset() would just free
these items and set C< co->ctx > to NULL.
leo