lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> Hello, I need a way to resume a coroutine in a way that does not blow out
> my stack in a tail call chain of many calls. Right now when i "return
> resume(..)" I consume the stack pretty quickly. Would it even be possible
> to do some sort of "tail resume"?

The standard way to handle that kind of scenario is to have some
dispatcher calling the coroutines in a loop. When one coroutine
wants to transfer control to another, it yields with some specific
value that instructs the dispatcher to resume that other coroutine.

-- Roberto