[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Suggestion: "usertype()" function
- From: Dirk Laurie <dirk.laurie@...>
- Date: Fri, 1 Jun 2012 08:46:03 +0200
2012/6/1 Tim Hill <email@example.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:
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.