lua-users home
lua-l archive

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


> 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...