3 ms·
> "The main limitation of Lua coroutines is that, since they are implemented with setjmp(3) and longjmp(3), you cannot use them to call from Lua into C code tha
by vaughan0 13y ago
> "The main limitation of Lua coroutines is that, since they are implemented with setjmp(3) and longjmp(3), you cannot use them to call from Lua into C code that calls back into Lua that calls back into C, because the nested longjmp will clobber the C function’s stack frames. (This is detected at runtime, rather than failing silently.)"
Lua 5.2 provides a mechanism to help with this: http://www.lua.org/manual/5.2/manual.html#4.7 http://www.lua.org/manual/5.2/manual.html#4.7
- silentbicycle 13y agoThanks. :) I'm still mostly using Lua 5.1.4 most of the time, and I forgot to include that.
- dottrap 13y agoThere is also a modification patch for Lua 5.1 called Cocos that fixes this. It was written by Mike Pall, better known as the author of LuaJIT. http://coco.luajit.org http://coco.luajit.org
- silentbicycle 13y agoI saw a patch he wrote for copying coroutines, for those who miss multi-shot continuations.