lua-users home
lua-l archive

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

On 7/10/07, David Welch <> wrote:

I am trying to write a C extension to lua and I am wondering what the
rules are when it comes to stack cleanup.
[snip code]
So this function is effectively type checking a tables field and
returning its value.  If the field doesn't exist then an error
is raised and a nil value is left on the stack.  If the field is there
but checkudata fails, once again a value is left on the stack.

What actually happens to the value left on the stack?  Can I basically
just forget about it?

error() (and luaL_check*() calls error()) unwinds the stack for you so
you don't have to worry about it. It's when there is no error() that
you should pay attention to your stack.