lua-users home
lua-l archive

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


Henk Boom wrote:
2009/6/11 Olivier Hamel <evilpineapple@cox.net>:
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

I'm guessing you meant to move "tblEnumList" into the internal
function's args, right?

function enum(strEnumSetName)
  typecheck(strEnumSetName, "string")
  typecheck(tblEnumList, "table")
  return function(tblEnumList)
      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

Yah, you can drop the second parameter of the enum func entirely, since it's not defined.