lua-users home
lua-l archive

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


Kacper Wysocki wrote:
On 7/10/07, David Welch <david.welch@thorcom.co.uk> wrote:
Hi,

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.

_K
Ok, thank you for clearing that up for me :-)

--
David Welch

Thorcom Systems Limited, Unit 4, 96B Blackpole Trading Estate West, Worcester, WR3 8TJ
Tel: +44 (0)1905 756700  Fax: +44 (0)1905 755777  Web: www.thorcom.co.uk
Registered in England and Wales number 2704696.