Stack size

You can get the index of the top element of the Lua stack with the int lua_gettop(lua_State*) function. The value this function returns will be the index of the top element on the Lua stack.

You can set the top element (size) of the stack with lua_settop(lua_State*, int). This function returns nothing. The second argument is the element that should be the index of the new top element on the stack. This function effectively resizes the stack. 

If the requested stack size with lua_settop is smaller than the previous size, all elements above the new top are simply discarded. If the requested stack size is greater than the previous one, all new elements will be filled with nil.

There is a lua_pop(lua_State*, int) macro defined in lua.h, which is a handy shortcut. This function will pop some elements off the stack, simply discarding them. The second argument of the function is how many elements to remove.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.232.189