lua-users home
lua-l archive

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

On Tue Oct 31, 2023 at 4:23 AM EDT, Thijs Schreijer wrote:
> This is a known issue with Lua coroutines, nested coroutines.

That's the thing! Thanks for telling me what words I was supposed to be

> Solutions are mediocre. Not because they are no good, but because they rely on every library in your application stack using the same approach, which makes it practically impossible to develop independent libraries that work across the board.

That makes sense. Although, the libraries you mention later seem to be
backwards-compatible with vanilla Lua coroutines, so would there be any
problems with just loading those and tricking external libraries into
using them?

> imho it should be dealt with on a Lua level. I actually discussed this with Roberto during the 2022 Lua workshop, and he had some ideas like a "goto" for coroutines. So hopefully we'll see this fixed in the next Lua version.

I kind of want to try implementing this in the Lua interpreter now. It
seems simple enough for the libraries that do it, but it looks like they
have to rely on being able to recursively descend through the nested
coroutines until Lua is executing the right one, so it could probably be
done even more elegantly with native support.