[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Lua 5.1 vs LuaJIT: pcall behavior differs
- From: Arseny Vakhrushev <arseny.vakhrushev@...>
- Date: Fri, 19 Aug 2011 13:15:01 +0400
Hello everyone, Mike!
Messing around with some wrappers in my code, I noticed a difference between Lua and LuaJIT pcall() behaviors. To be short, please consider the following:
$ lua -e 'local f = coroutine.wrap(function () assert(pcall(function () print "before" ; coroutine.yield() ; print "after" ; end)) end) ; f() ; f()'
before
lua: (command line):1: (command line):1: attempt to yield across metamethod/C-call boundary
stack traceback:
[C]: in function 'f'
(command line):1: in main chunk
[C]: ?
... which is normal. The 'pcall' is the C-call boundary here. However, ...
$ luajit-2.0.0-beta8 -e 'local f = coroutine.wrap(function () assert(pcall(function () print "before" ; coroutine.yield() ; print "after" ; end)) end) ; f() ; f()'
before
after
Is pcall() in LuaJIT yieldable or am I missing something? Things like:
$ luajit-2.0.0-beta8 -e 'assert(pcall(function () coroutine.yield() end))'
luajit-2.0.0-beta8: (command line):1: (command line):1: attempt to yield across C-call boundary
stack traceback:
[C]: in function 'assert'
(command line):1: in main chunk
[C]: ?
... don't work of course, but it seems that the C-call boundary here isn't 'pcall' itself but the main call of the '-e' chunk.
Thanks for clarifying!
// Seny