lua-users home
lua-l archive

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


On Monday, April 21, 2014 07:34:40 PM Ross Bencina wrote:
> I just wanted to add my support to your idea. Thanks for the patches. I
> think that what you are proposing is a useful idea. If a similar
> mechanism was available as part of Lua core I would use it.
> 
> The problem for me with light userdata is that they are typeless (like a
> void pointer in C). There is no built-in way for either Lua nor C to
> associate a type with the pointer. This becomes a problem as soon as
> light user data is used for two distinct purposes in the code.

You can associate an extended type using a weak-keyed table. (But now that I 
remember light userdata doesn't create garbage, the table needs to be manually 
curated to remove dead pointers.) And it only adds overhead for each userdata 
you assign a type to. The patch costs an extra field in every value, not just 
userdata. I don't see what you gain from doing this.

-- 
tom <telliamed@whoopdedo.org>