lua-users home
lua-l archive

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


With Lua 5.2 you can yield across a CFunction, which will longjmp()
across it when you have:

  Lua -> CFunction -> Lua

Would it ever make sense for Lua to allow longjmp() across Lua?

  CFunction -> Lua -> CFunction

If a Lua program calls my CFunction and I longjmp() across Lua to my
enclosing CFunction, I could imagine a world where calling back into
Lua later would act as though my inner CFunction had just returned.

Is this likely to ever happen?  Has anyone ever asked for this before,
or wished they had it?  I'm not asking for this functionality, just
wondering if it's even remotely feasible or likely to ever be
supported.

In an interesting thought experiment, this would allow different Lua
interpreters to call into each other and yield across each other.  I'm
having trouble thinking of a practical use case for this though.  :)

A more realistic use case would be integrating Lua with another
runtime/VM that also has some notion of resumable coroutines.  If the
other VM used Lua to handle callbacks, and those callbacks call back
into the VM, the VM might want to suspend its coroutine and resume the
Lua callback later.

Thanks,
Josh