lua-users home
lua-l archive

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


On 2017-10-06 03:46, ? ? wrote:
In Manual §2.4 in the description of __add metamethod:
If any operand for an addition is not a number (nor a string coercible to a number), Lua will try to call a metamethod. First, Lua will check the first operand (even if it is valid). ...

What does "(even if it is valid)" mean here?

Valid for the operation (here: addition), as in "a number (or a string
coercible to a number)".

The intention is to express that Lua always looks for a metamethod on
the left operand first, failing that on the second (and failing that
throws an error), no matter the types of the values.

-- nobody