lua-users home
lua-l archive

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


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.

-- 
tom <telliamed@whoopdedo.org>