Описание тега metatable
Typically it refers to a feature of Lua which allows a programmer to change the behaviour of tables. The meaning may be dependant on other tags used with it.
In Lua a metatable is used to contain metadata or metafunctions for any Lua value.
There are certain fields within a metatable which (if they exist) have specific responsibilities when used with operators. These are __add
, __sub
, __mul
, __div
, __mod
, __pow
, __unm
, __concat
, __len
, __eq
, __lt
, __le
, __index
, __newindex
, and __call
.
A metatable can have its own metatable and this is known as metatable chaining.
For more information see the Lua reference manual. For a detailed description about meta-tables and meta-methods, see PiL (Programming in Lua). A few of metamethods available are:
- Arithmetic Metamethods
- Relational Metamethods
- Library-Defined Metamethods
Table-Access Metamethods
- The
__index
Metamethod - The
__newindex
Metamethod - Tables with Default Values
- Tracking lua-table accesses
- The