lua-users home
lua-l archive

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


Hi all,

I have a question that I'd like more experience users to answer.

Imagine I'm writing a C function to be called from Lua.

This C function receives 10 arguments in the Lua stack.

If I detect an error on, say, the first argument, may I do this?

if (error on the first argument) {
  lua_pushnil(L);
  lua_pushstring(L, "Error on first argument");
  return 2;
}

So that I return 2 arguments : nil and an error string?

If so, what happens with the other 10 elements in the stack? Does Lua clean the up automatically or am I supposed to clean all the arguments before pushing my return values in the stack?

Thanks,
Antonio