lua-users home
lua-l archive

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

On this day of 01/18/2008 09:14 PM, Greg Fitzgerald saw fit to scribe:
> Hi Luiz,
>>> Would there be any downside to Lua's 'type()' returning the value of a
>>> '__type' metamethod if its type is 'userdata'?
>>> return t == "userdata" and mt and mt.__type or t
>> Yes, it'd break all programs that rely on type returning "userdata"...
> How so?  It would only break programs with userdata types that have a
> metamethod named "__type".  All others would continue to return
> "userdata".  Do many (any?) Lua programs make use of a __type metamethod?

It's not that it would break programs that already have __type (although
it would do that too); more importantly it would break programs that
depending on seeing 'userdata' and not, say, 'carray' from a call to
'type' on an object, in order to distinguish userdata from other types.

- David