lua-users home
lua-l archive

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


Peter Odding wrote:
> dormando wrote:
>> I do have one real question however; I have the 2nd ed PiL book, the
>> 5.1 ref man, and the online manual. All of which devote a single
>> sentence saying that lightuserdata does not have a metatable.
>> However, this appears to not be the case :P It has a single
>> metatable for all types (like numbers, strings, etc). So when I set
>> another metatable for the second lightuserdata object, it overwrote
>> it globally. 
> 
> [...]
> 
> So this is in fact documented, though I must admit I wasn't aware of
> it either. 

Section 2.8 - Metatables [1] of the online manual starts with the
sentence:

> Every value in Lua may have a metatable.

A few lines below you can also read:

> Tables and userdata have individual metatables (although multiple
> tables and userdata can share their metatables); values of all other
> types share one single metatable per type. So, there is one single
> metatable for all numbers, and for all strings, etc.

Maybe that would be clearer with "Tables and full userdata have
individual metatables".

[1] http://www.lua.org/manual/5.1/manual.html#2.8