lua-users home
lua-l archive

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


> 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:

  http://www.lua.org/manual/5.3/manual.html#2.4

  "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".

-- Roberto