lua-users home
lua-l archive

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


On Sat, Mar 20, 2010 at 6:30 AM, Roberto Ierusalimschy
<roberto@inf.puc-rio.br> wrote:
>> As a related question, is it legal in Lua 5.2 to use coroutine.yield
>> from within a hook callback? [...]
>
> This was already legal in 5.1.
>
> -- Roberto

Odd; I tried using it (in both 5.1.4 and 5.2 work2) yesterday, and
coroutine.yield returned "attempt to yield across metamethod/C-call
boundary". Here's the code I used:

----
co = coroutine.create(function() for i=1,100 do print(i) end end)
debug.sethook(co, function() print("hooked") coroutine.yield() end, "", 1)
print(coroutine.resume())
----
Output:
hooked
false attempt to yield across metamethod/C-call boundary
----

~Jonathan