[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: pop user values in C functions
- From: Marc Balmer <marc@...>
- Date: Tue, 10 May 2016 14:31:21 +0200
> Am 10.05.2016 um 14:25 schrieb Marc Balmer <email@example.com>:
> ... 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...