Are coroutines broken? (or is this some new/different behavior?)
Patrick R. Michaud
pmichaud at pobox.com
Sat Apr 21 14:55:32 UTC 2012
On Sat, Apr 21, 2012 at 06:48:08AM -0400, Andrew Whitworth wrote:
> Techically not "broken", though it is behavior I've never quite agreed
> with. When a coroutine returns, it is considered "dead" and cannot be
> executed again. This makes them, I think, quite useless for most
> possible applications.
>
> I thought there was a way to manually reset the coroutine to get it
> invokable again. However, looking at the code I don't see any such
> thing.
Rakudo uses coroutines extensively for its gather/take construct.
The trick is to only execute clones of the coroutine itself; the clones
eventually reach the "dead" state, but the original uninvoked coroutine
is always available for producing fresh copies to restart from.
Pm
More information about the parrot-dev
mailing list