lua-users home
lua-l archive

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


2018-02-18 18:37 GMT+02:00 Albert Chan <albertmcchan@yahoo.com>:
> I have trouble using Lua C stack, even in C
>
> Say, I have a c function A that uses lua stack, that call another c function B
> that also uses c lua stack.  however, B did a lua_settop of 1, then return 1.
>
> Sine both c functions share the same stack, A loses everything except the result of B

They do not. Every call generates a new stack frame, and no function
can see further back than its own arguments, except those values that
have been exported into its closure as upvalues. What you describe
cannot happen.