|
On 05/10/2016 02:31 PM, Marc Balmer
wrote:
Exactly, the only reason you may want to pop off values is keeping the statck small (below LUA_MINSTACK which is usually 20) during the function.Am 10.05.2016 um 14:25 schrieb Marc Balmer <marc@msys.ch>: ... I am getting slightly confused from to much hacking, so in a function that creates new uservalues, can I just leave them on the stack? Will Lua automatically remove/pop excess values from the stock when the function returns (e.g. I create four temp uservalues and one result that I actually need. Then I return 1. Will the four uservalues do any harm?The manual says "To return values to Lua, a C function just pushes them onto the stack, in direct order (the first result is pushed first), and returns the number of results. Any other value in the stack below the results will be properly discarded by Lua.". So no need to pop values off the stack... At the end of a function it doesn't make any sense. -- Thomas |