lua-users home
lua-l archive

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



On 03/03/2014 09:27 AM, dehmel.r@atg-lm.com wrote:
Is this lua_settop(L, 0) or any other remove, ... not needed?

static int Lcm_smw16(lua_State *L)
{
  Lcm* ud = (Lcm*)luaL_checkudata(L, 1, "Lcm");
  int a = luaL_checkint(L, 2);
  int d = luaL_checkint(L, 3);
  int blind = luaL_optint(L, 4, 0);
  lua_settop(L, 0); // <=== no need for this stack adjustment ?
  lua_pushnumber(L, ud->smw16(a, d, blind));
  return 1;
}
Exactly, it's not needed. The return 1 already tells the interpreter that you only return the top element of the stack.
--
Thomas