[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Stack usage behaviour
- From: Marc Lepage <mlepage@...>
- Date: Mon, 11 Nov 2013 12:36:22 -0500
Hi I assume you are talking about a Lua function written in C using the C API, called from Lua (or from C via the API).
In this case, in your function the parameters will be on the stack in first/second/third order (if you had 3 params). Push your results on the stack and return how many results you are returning. Lua will take care of the rest.
So if you have one param and return one result, you can push your result on top of your param and return 1, you don't need to pop the param first. If you want to return two results, push them both and return 2.
The only catch is you have to ensure there is enough stack space if you are using the stack a lot.