lua-users home
lua-l archive

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


On Fri, Jun 12, 2015 at 3:14 PM, Tim Hill <drtimhill@gmail.com> wrote:
> What is the reason luaL_callmeta() only allows one return value? I’m guessing it’s because it’s primarily targetted for metamethods like __add(). However, it would be great if there was a luaL_callmetax() that had an explicit argument for the number of return values (or LUA_MULTRET).
>
> Not academic: All my projects to date have needed this (of course I’ve created my own, but it’s surprising that it’s not there for things like __pairs() etc).

With the exception of the special-case __call, all metamethod
operations implicitly truncate results to 1 value in the language, I
don't think a special case for C makes sense. How surprising would it
be if

a(b+1)

passed more than one argument to a?

Fortunately for __call, you can easily use lua_call instead.

-- 
Patrick Donnelly