lua-users home
lua-l archive

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


2012/6/1 Tim Hill <drtimhill@gmail.com>:
> My point really was that the ability to project "metatype" information for
> userdata and tables is, imho, something that should be part of the standard
> base language.
...
> After all, any predicate system can really be built on top of an
> extended (two return value) type() function plus a conventionalized use of
> the second return value (string parsing etc etc).

I'm happy with extending `type` in that way for userdata.  The second
return value could be the actual metatype associated with the metatable
in the registry.  This is already available to a resourceful user, as
Luiz pointed out here:

    http://lua-users.org/lists/lua-l/2012-01/msg00318.html

This value needs be unique anyway (it is a table key) so there is
no danger of a namespace collision.  And even though one can implement
this purely at the Lua level, searching all of the registry every time
is clearly inefficient.

But tables?  No.