Lua 5.2 and LuaJIT resume/yield issue
Posted: Tue Jun 04, 2013 1:21 am
Hi,
I'm desadoc/Erivaldo from Brazil, I'm new to love2D and this is my first post here. Please forgive my english and typos
Early today I wrote some code with resume/yield that didn't work. The code was +- like this:
The stack trace told me the problem was an "attempt to yield across metamethod/C-call boundary...". I googled that and found that Lua 5.2 and Coco/LuaJIT supposedly support that kind of yield. I decided to try love2D with Lua 5.2 first and the error, as I expected, disappeared. Then I tried LuaJIT. All builds that I found here in the forum gave me the same error. The last test I did was to download the latest stable LuaJIT, compile it and try the following code (that runs fine with Lua 5.2 too):
Is LuaJIT really broken? Or is it my fault? And in that case, is there some way to write that code so it works with LuaJIT too?
I'm desadoc/Erivaldo from Brazil, I'm new to love2D and this is my first post here. Please forgive my english and typos
Early today I wrote some code with resume/yield that didn't work. The code was +- like this:
Code: Select all
-- main.lua
function love.load()
local co = coroutine.create(function() dofile("myscript.lua") end)
coroutine.resume(co)
end
-- myscript.lua
coroutine.yield()
Code: Select all
local function hook(event, line)
print(debug.traceback())
coroutine.yield()
end
local pr = assert(load("print\"hi?\""))
local cr = coroutine.create(pr)
debug.sethook(cr, hook, "clr")
print(coroutine.resume(cr))