Lua的Full UserData、Light UserData和metatable

http://lua.2524044.n2.nabble.com/LightUserData-and-metatables-td3807698.html

https://www.lua.org/manual/5.3/manual.html#2.4

https://www.lua.org/manual/5.0/manual.html#3.8

"... do you realize that by setting the metatable of a light userdata

you are actually setting the metatable of all light userdata at once ?"

I did not realise this. oops.

设置Full UserData的metatable设置的是一个Full UserData实例的metatable。

设置Light UserData的metatable设置的是所有Light UserData实例的metatable。

Tables and full userdata have individual metatables (although multiple tables and userdata can share their metatables). Values of all other types share one single metatable per type; that is, there is one single metatable for all numbers, one for all strings, etc. By default, a value has no metatable, but the string library sets a metatable for the string type (see §6.4).

只有Table和Full UserData有独立的metatable,其他类型的值共享一个metatable。