lua-users home
lua-l archive

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

> On Feb 20, 2017, at 10:26 PM, Dirk Laurie <> wrote:
> 2017-02-20 14:15 GMT+02:00 Francisco Olarte <>:
>> 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.

If I understand the OP correctly, he is saying that __add() will accept a callable, so why not __call()? I haven’t tested this but *if* he is correct, then that appears to differ from the Lua reference 2.4 that says "Note that queries for metamethods are always raw; the access to a metamethod does not invoke other metamethods.” So either he is wrong, the Lua ref manual is wrong, or the Lua code is wrong (I’m not taking bets here!).