lua-users home
lua-l archive

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

Am 20.11.2013 23:24 schröbte Andrew Starks:

What do you think about  something like `getudtype(userdatavalue)`,
where the field name from the registry or something like a __type
field value would be returned.

Again, easy to add if you've got debug. I find that as a Lua user,
knowing the *kind* of userdata that I'm holding is sometimes relevant.

What for? You are not accessing the userdata's memory directly from Lua so you don't *need* the actual userdata type for type safety, and if you check for it anyway you run into the same issues as with function/is_callable, i.e. you lose the ability to pass e.g. a mock object instead of the real thing (or an object "writing" to an array instead of a real file object) ...