lua-users home
lua-l archive

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


On Tue, Sep 22, 2020 at 12:11 AM 孙世龙 sunshilong <sunshilong369@gmail.com> wrote:
> How to comprehend that Lua automatically removes whatever is in the
> stack below the results after the function returned?
> How does it achieve this goal?

The 'contract' between the interpreter and your code explicitly does
not require you to clean up the unneeded stack values when returning
from a C routine, how the interpreter manages that is an
implementation detail, which could change from version to version. It
could be that this stack is a chunk of memory allocated just before
the call and freed after, or that the interpreter just removes those
entries for you. I have never looked at those details because I don't
really need to know to write the code.



-- 
Gé