lua-users home
lua-l archive

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


I feel like I should be able to do this, but I can't see how to do it
with the existing fallbacks. I want to have a tag method called when a
global variable dosn't exist.

I want to do this because I want to separate 'enum' types from the
current global table, but I want them to have global scope. In the
end, it will look something like this:

enums = { 
    dog_names = {
          ROVER = 1,
          SPOT  = 2,
          FIDO = 3
    },
    car_makes = {
          HONDA = 1,
          FORD = 2,
          NISSAN = 3
    }
}

function e_type(varname) 
  local enum_value
  local enum_name

  enum_value,enum_name = find_enum(varname);
  return enum_name
end

print(ROVER) -- 1
print(NISSAN) -- 3
print(e_type("ROVER")) -- dog_names

-- 
David Jeske (N9LCA) + http://www.chat.net/~jeske/ + jeske@chat.net