lua-users home
lua-l archive

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


2017-02-20 14:15 GMT+02:00 Francisco Olarte <folarte@peoplecall.com>:

> Reading "2.4 – Metatables and Metamethods" the only hint I get of
> metatable methods needing to be functions is the end of the first
> paragraph " Lua checks for a function in the field "__add" of the
> value's metatable. If it finds one, Lua calls this function to perform
> the addition. ".
...
> So, if the metamethod for __call NEEDS to be a real function, I think
> it should be clearly indicated in its documentation.

The blanket requiremend is that _all_ metamethods should be
functions.

The two exceptions (__index and __newindex) are very clearly
documented. In the first case, it says "Despite the name, the
metamethod for this event can be either a function or a table."

Since at the entry for __call does not say anything of the kind,
the implication is that the metamethod cannot be a table.

There are many, many places in the manual where something
appears to be unspecified if you only read that sentence or two,
but focuses into clarity when you take account information given
elsewhere.