Many times I need to have a variable to express the type of something, but as you probably know it is also the name of a function in Lua.
What could be a proper workaround? I thought of:
- Use it anyways. Since I use almost only local values, the type function isn't overwritten but it becomes temporarily inaccessible (also a problem when used as an argument name).
- Using a synonym of the word "type" (probably the easiest solution), but I can't come up with anything good.
- Using upper case, prefix/suffix, like
Type
,TYPE
or_type
, but it goes against the code style used so far. - Save the type function as something else and restore it at the end.
- Add a global reference to
type
called for example 'typeof' so that when type is used locally I can still use typeof. - Recompile Lua with a different name for the type function (no thanks!)