Re: FFI metatypeof

  • From: Mike Pall <mike-1206@xxxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Tue, 12 Jun 2012 16:10:18 +0200

Richard Hundt wrote:
> I'd like to get a reference to the metatable set via ffi.metatype()
> far away from where it is set (for type checking, etc.).

Umm, why? There's already ffi.istype().

The FFI already checks that cdata arguments passed to metamethods
are of the correct type. ffi.istype() is still useful for binary
operators with mixed arguments. But that takes the cdata type
(which you already have).

[
Also, please have a look at the roadmap. The planned metatable
optimizations for LuaJIT 2.1 might have an asymmetric cost model
for metatables and __index tables:

* Calling metamethods will be a lot cheaper.
* Setting a metatable for an object (once) is cheap.
* Getting the metatable may be expensive.
* Modifying a metatable is very expensive.

I don't think I should introduce new functionality that would
thwart this effort.
]

--Mike

Other related posts: