lua-users home
lua-l archive

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

I've done this by overriding 'type()' to look for a '__type' field in the metatable, first.

Allows me to have userdata that reports as enum, xxx (xxx being the enum family name, yes, type() returns two values then.

Could use the same for making a table return class, xxx or anything.

Changing this does not need changes in Lua itself, but a common convention could be good to have. My code for doing this is in a separate 'type.lua' that will be require'd by code relying on this behaviour.


Stephen Kellett kirjoitti 17.8.2007 kello 12:24:

Patrick Donnelly wrote:
I'm curious what features people would like to see added to Lua.

This comment is from the perspective of a software tool developer. In that context I am talking about inspecting Lua internals and Lua objects from C.

I'd like to see the ability to actually get a class name for a class object. Currently when you query an object for its type (from C) you just get "Table", which is not very useful. Its much more useful to know that a "Weeble" object is possibly leaking (look there are 10,000 of the critters!) rather than noticing the Table count has increased by 10,000.

I was talking with Bob Pappas from Adobe(*) yesterday (we were talking about the Lua Memory Validator product I am involved with) and this issue came up - he had lots of Table objects but we couldn't tell which class/type each object was. It limits the info you can get from a tool like Lua Memory Validator (or any tools like it, not that I am aware of any others for Lua).


(*) Sorry the name dropping but I've mentioned this because it did happen and it shows that big names are using Lua and interested in issues such as this.