[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: yield across metamethod/C-call boundary
- From: Stefan Brantschen <sbr@...>
- Date: Thu, 17 Aug 2006 07:53:03 +0200
On 16 Aug 2006, at 23:00, Mike Pall wrote:
A C hook function is called without creating a Lua stack frame.
This of course means it's not visible in the stack trace.
Yes, right, I should have thought of that. Thanks.
What works, though, is resuming in a hook (and yielding to it), like so
local function proxy()
for i = 1, 2 do
print(debug.traceback())
coroutine.yield()
end
end
local pr = coroutine.create(proxy)
local function hook(event, line)
print(debug.traceback())
coroutine.resume(pr)
end
local mp = assert(loadfile("test.lua"))
local cr = coroutine.create(mp)
debug.sethook(cr, hook, "clr")
print(coroutine.resume(cr))
(The resume in 'hook' will try to resume the dead coroutine 'pr' a
few times after it has terminated in this simple example.)
Thanks for your support.
- Stefan