lua-users home
lua-l archive

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


On 7 April 2015 at 22:01, Javier Guerra Giraldez <javier@guerrag.com> wrote:
> In LuaJIT, methametods are added to ffi objects using the
> `ffi.metatype(ct, metatable)`, where `ct` is the ffi type and
> `metatable` is compatible with the plain Lua metatable.  But the user
> is not allowed to modify the metatable, its contents, or it's __index
> contents after the call to metatype().
>
> I guess that allows LuaJIT to statically set all the function
> bindings, and the result is that adding simple methods to ffi objects
> is _very_ efficient, and typically gets fully compiled.

That's very interesting ... so essentially it is allowing user to
define metatable only once - no changes allowed, so then it is free to
optimise the way the metatable is used?

Re compilation - I suspect LuaJIT also uses a more efficient call
mechanism? In Ravi all calls go via luaD_precall() / luaD_call() so it
may not be as optimum.

Regards
Dibyeneu