lua-users home
lua-l archive

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




On 26/08/15 04:35 PM, Sean Conner wrote:
It was thus said that the Great Soni L. once stated:
I'd rather have multiple levels of metatables.

Value level
Scope level
Function level
Module level
Global level
   Could you give an example of how this would work?

   -spc




debug.setmetatable sets global per-type metatable, setmetatable sets local per-value metatable, setmetatype sets per-chunk per-type metatable. (this doesn't support per-scope but meh w/e), debug.setmetatype(chunk, obj, table) sets per-chunk per-type metatable.

debug.getmetatype/debug.getmetatable/getmetatype/getmetatable gets metatables.

Not sure how we would __metatable.

--
Disclaimer: these emails are public and can be accessed from <TODO: get a non-DHCP IP and put it here>. If you do not agree with this, DO NOT REPLY.