lua-users home
lua-l archive

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


On 2/28/06, nvleer <nvleer@myway.com> wrote:
The results of a function call are the (n) items at the top of the stack.    Lua should save and restore the state of the stack, including moving the results to the proper position on the stack (in luaD_poscall).  So, I don't believe you need to clean everything before pushing your returns, although that might be considered good form.

Yes, I was pretty sure that you don't _have_ to clean up after a function call but it just feels wrong to leave all that stuff on the stack.

For now I am assuming that a table value can be safely removed from the stack after retrieval with lua_getfield.  After some testing I see the pointers (string or whatever) are exactly the same and point to the entry inside the table.  That should never be collected until the table itself is collected.  Of course that might change in the future but I don't know what else to do without official guidance.  In fact, I'm not sure why that would ever change in the future because it would make things less efficient.

--
// Chris