lua-users home
lua-l archive

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


On 22/04/2014 5:14 PM, Coroutines wrote:
On Tue, Apr 22, 2014 at 12:09 AM, Philipp Janda<siffiejoe@gmx.net>  wrote:

>>What I gain is the ability to verify the type safety of light userdata
>>usage on the C side
Ahah!  I get what's going on ITT now. :-)

Maintain a vector of addresses that are copies of the lightuserdata
for the particular type you're checking for.  Keep it sorted for
binary-searching it later.  Not as light as what you're suggesting,
but it wouldn't require modifying Lua if this proposal doesn't get
accepted :>

Yep, or a hash table.

Or you could use spare bits of the C pointer as was suggested earlier.

Or if your objects are allocated from a slab you can do a pointer range check.

Sorry to change my tune, but more and more I am thinking that the killer feature of this patch is the ability to have multiple classes of light userdata each with their own metatable. This allows operator overloading for a particular class. Which would be neat if one of your light userdata happened to have algebraic structure.

Ross.