lua-users home
lua-l archive

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


Olivier Hamel wrote:
Note that it's not permitted to do:

enum "Test"
{
   "Div",
   "Multi",
   "Add",
   "Sub",
   "Assign",
   "Call"
}
Gah! I'm an idiot, Sorry! Here:

function enum(strEnumSetName, tblEnumList)
   typecheck(strEnumSetName, "string")
   typecheck(tblEnumList, "table")
   return function()
       for k, v in ipairs(tblEnumList) do
          HackEnumCntr = HackEnumCntr + 1
_G[k] = 2^HackEnumCntr -- Figure something for handling over overflows?
          -- Is it even a possible concern? Never was in my experience...
       end
   end
end

Olivier