|
However, it seems to me that there is one hole in this clean model: the inability of a metatable to project a "type" into the Lua code space. Specifically, regardless of metatable, the value of type(someuserdata) is always "userdata". This means if I have several different userdata "types" in Lua code I cannot use them polymorphically without tracking their type manually (using, say, an ephemeron table). While tostring() can be used as a workaround (as it is for example with file handles) this seems too much like a hack to me; tostring() is supposed to return a value, not a type.