[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: return values of metamethods
- From: Roberto Ierusalimschy <roberto@...>
- Date: Tue, 2 Feb 2016 14:42:47 -0200
> I may be missing something obvious, but there does not seem to be any
> consistent documentation in the current manual on the return values of
> metamethods. For example, nothing is said about the return value of the
> index metamethod when it is a function. In particular, what should happen
> if the function returns more than one value? I just had to debug some weird
> behaviour which was caused by such a metamethod, so I would be tempted to
> say it is wrong to return anything but one value, but that is not supported
> by official docs.
In fact, the manual says nothing about __index. But there is explicit
documentation for the return values of most (all?) other metamethods:
"add": [...] If Lua can find a metamethod, it calls the metamethod
with the two operands as arguments, and the result of the call
(adjusted to one value) is the result of the operation.
We will repeat that for "index".