lua-users home
lua-l archive

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




On Tue, Aug 20, 2019 at 4:24 AM Andreas Falkenhahn <andreas@falkenhahn.com> wrote:
There's probably a misunderstanding here: Of course I'm not intending to have the C function continue where it left off. This is obviously impossible. I just want the C function to be called again. The C function code will always be run from its entry point, not from somewhere in between.


You'd be better off switching to Lua 5.3, where you can use lua_yieldk to specify a C function that's called on resume. This function will find the Lua stack as you left it, with the results yielded replaced by the arguments to resume.

I have not used lua_yieldk much, but I do use lua_callk an awful lot so Lua code can call C code that then calls Lua code, which can yield if it wants to.


--