[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: C extension and stack cleanup on error
- From: David Welch <david.welch@...>
- Date: Tue, 10 Jul 2007 11:16:00 +0100
Kacper Wysocki wrote:
On 7/10/07, David Welch <email@example.com> 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.
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.
Ok, thank you for clearing that up for me :-)
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.