parent state and have userdata with a custom __gc as the values. When
the coroutines get collected, so will the userdata.
Graham Wakefield wrote:
> This won't work. The registry is shared between the main state and all
> child states created within it.
You're right. I wrongly assumed that each coroutine had its
own registry. Thanks for pointing that out!
Then, Rici's advice is probably the best.
There is (at least) one more way to achieve that goal: create
a userdata with a __gc method and put it on the coroutine's
stack (say, as the 1-st parameter to the coroutine's main function).
(Tested today, and seems to work).