lua-users home
lua-l archive

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


Why do you want to “clean” the stack? You may be making things harder than they are. Lua manages the “stack” for you.



Sent from my iPhone

On Feb 24, 2021, at 7:26 PM, Ranier Vilela <ranier.vf@gmail.com> wrote:


Hi Hackers,
How should the stack look after the calls below?

    lua_pushinteger(L, p1);
    lua_pushinteger(L, p2);
    lua_pushinteger(L, p3);
    lua_pushnumber(L, p4);
    lua_call(L, 4, 1);
    if (lua_isuserdata(L, -1)) {
        value = lua_tonumber(L, -1);
        lua_pop(L, 1);
    }
    lua_pop(L, lua_gettop(L));

What is the correct way to clean the stack?

regards,
Ranier Vilela