[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Feature Request: type() consult __type for userdata
- From: David Haley <dchaley@...>
- Date: Fri, 18 Jan 2008 23:04:10 -0800
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.