currently I'm building my own script VM manager class in C++, I have no problems with any of the lua & lua C or C++ stuff, but the one section that confuses me is: when to use lua_pop
and when to use lua_remove
.
From what I understand, lua_pop
is to remove multiple values(on the stack) from the top down, eliminating data that is no longer needed, where as lua_remove
is for removing a single value from any arbitrary, valid stack index(basically what the lua manual says for both :P).
but I've noticed ceratin segments of code scattered around the web that intermix lua_pop
and lua_remove
, but when I tried to use lua_pop
instead of lua_remove
where the call just removed the top stack element, I ran into problems, so would it be possible to get a definitive example or explaination on how and when to use these two functions correctly, as well as reletive speed & efficency for these two(I assume lua_pop
is faster than lua_remove
, which is one of the reasons why I want to use lua_pop
as much as possible, apart from coding 'correct code')
thanks :)