Current parrot behaviour for exhausted yields is dying with "Cannot
resume dead coroutine."

parrot coros are designed after lua, but lua does return nil and as
2nd return value announces also "cannot resume dead coroutine". most
lisp's also behave the same way.
As third version the parrot book announced coros to be auto-resetting.

This makes no sense to me at all, as coros are usually needed to fetch
elements from a lazy list, and when the list is exhausted the state
should return to the head of the list automatically? lazy cycling a la

rakudo deals with the dead coroutine exception by looping at the end
of all yield states, as far as I understand it.

I've implemented now the feature that the coro PMC can be reset.
I'd like to propose that not as described in the book, as auto-reset.
The default should stay as it is.
But as new feature coros can now use the reset method, and maybe add
an attribute to use autoreset.

I could also return PMCNULL when the coro is dead the first time, and
only die every subsequent time. This would make sense to me also.


The implementations are at the parrot branches rurban/coro-reset-gh564
for the method and rurban/coros-gh564 for autoreset but is not yet
I'll provide a smoke-me/coros-gh564 with my proposal later.
Reini Urban

Reply via email to