in reply to Re (tilly) 1: Perl 6 coroutines (RFC 31)
in thread Perl 6 coroutines (RFC 31)
I've speculated about using "fibers" in Win32 to implement iterators that can yeild. Calling the function in its own super-lightweight thread means it can keep its stack, so it doesn't need to return but can yeild and keep looping. I never wrote up that article (yet) though.
You can also do iterator, today, using objects.
The code behind ++ would have to save its state and return each time, so it's harder to write than having a yeild. But you declare the iterator instance and can use that one (or another one).my $iterator= $container->iterate(); while (my $item= $iterator++) { process $$item; }
What if yeild caused the call to return a token, and that is what you make subsequent calls on? You can have another one going without conflict.
I agree that it doesn't sound like co-routines as described in classic literature. Those would "call" each other, rather than having a yeild statement at all. Such co-routines as members of the same object would also make sense.
—John
|
---|
Replies are listed 'Best First'. | |
---|---|
Re (tilly) 3: Perl 6 coroutines (RFC 31)
by tilly (Archbishop) on Jul 13, 2001 at 20:58 UTC | |
by John M. Dlugosz (Monsignor) on Jul 13, 2001 at 22:24 UTC |
In Section
Meditations