lua-users home
lua-l archive

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


On 04/21/2014 05:57 AM, Tom N Harris wrote:
On Sunday, April 20, 2014 07:50:42 PM Peng Zhicheng wrote:
then I thought, maybe I could go one step further, thus the second patch. I
added a secondary tag (what I called type extention, but sadlly I couldn't
think out a better name for that. maybe subtype?) into the TValue struct, I
even give each subtype of lightuserdata a seperate metatable.
local UDTypes = setmetatable({}, {__mode = "k"})

function setuserdatatype(ud, xtype)
   UDTypes[ud] = xtype
end

function getuserdatatype(ud)
   return UDTypes[ud]
end

Maybe I'm missing something, but I don't see why do you need to modify Lua to
do this.


thanks for your suggestion.

actuall I had played with several solutions, including the one you suggest.

by providing the patches, I'm not saying they are better sulutions I found.

I just feel the current two userdata types are either `too light' or `too heavy'
it might be an interesting idea to have something inbetween.