Re: FFI metatypeof

  • From: Mike Pall <mike-1206@xxxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Tue, 12 Jun 2012 17:56:03 +0200

Richard Hundt wrote:
> local cmeta = debug.getmetatable(1LL)
> local index = cmeta.__index
> local cbase = { 
>    lshift = function(a, b)
>       return bit.lshift(tonumber(a), tonumber(b))
>    end 
> }
> cmeta.__index = function(o, k)
>    return cbase[k] or index(o, k)
> end

That's not a good idea. This breaks internal tail calls used by
cdata metamethods, it breaks cdata error reporting and the JIT
compiler won't cope with that, too. The base metatable for cdata
type is definitely off-limits.

--Mike

Other related posts: