lua-users home
lua-l archive

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


The following is a moderately radical change proposal since it requires a
recompilation of extension modules. It was inspired by Lunar's call member
function.

Would it be reasonable to make the error code be negative numbers? lua_call
could already do this, but lua_pcall currently uses positive values for
error codes.

The benefit to that is that then lua_call and lua_pcall could return the
number of results thereby saving the need to save the call base when making
a call that generates multiple return values. Furthermore, with C compilers
that support tail call optimization, one can then write:

    return lua_call( L, argCount, LUA_MULTRET );

Extending this further, one could actually define the handling for Lua C
functions to allow negative results to signal errors and allow lua_pcall to
be used in the same way.

Mark