lua-users home
lua-l archive

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


The 5.2 reference manual states the stack behavior of luaL_len as [-0, +1, e].

But judging by lauxlib.c, it looks like it's instead [-0, +0, e].

    LUALIB_API int luaL_len (lua_State *L, int idx) {
      int l;
      int isnum;
      lua_len(L, idx); /* <---- this pushes an object to stack */
      l = (int)lua_tointegerx(L, -1, &isnum);
      if (!isnum)
        luaL_error(L, "object length is not a number");
      lua_pop(L, 1);  /* remove object <----- but notice */
      return l;
    }

-- 
Jim Pryor
dubiousjim@gmail.com