lua-users home
lua-l archive

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


On 9/19/2010 9:14 PM, Jonathan Castello wrote:
Maybe metamethod calls have an extra C-call that precede them?

The other way around, actually. A call to a Lua function avoids 
increasing the call depth in the VM. The key statement is a 'goto' in 
the handling of OP_CALL. It just resumes the same loop with a different 
frame. When a metamethod is invoked, the function goes through luaD_call 
which calls to a nested luaV_execute.
So I'm thinking it might be nice to handle metamethods the same way. 
When a metamethod is encountered that is a Lua function, instead of 
nesting, just set up the call frame then return to the execute loop with 
a restart flag. I think it's correct to assume that any single 
instruction can be replaced with a OP_CALL to an equivalent function and 
nothing will go haywire.
--
- tom
telliamed@whoopdedo.org