[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Why is the stack cleared on panic?
- From: Julio Merino <jmmv84@...>
- Date: Mon, 10 Jan 2011 16:37:25 +0000
On Mon, Jan 10, 2011 at 4:29 PM, Alexander Gladysh <agladysh@gmail.com> wrote:
> On Mon, Jan 10, 2011 at 18:50, Julio Merino <jmmv84@gmail.com> wrote:
>
>> static jmp_buf buf;
>
>> int panic_handler(lua_State* s)
>> {
>> longjmp(buf, 1);
>> }
>
>> void safe_gettable(lua_State* s, const int index)
>> {
>> if (setjmp(buf) == 0)
>> lua_gettable(s, index);
>> else
>> throw error('Uh oh, lua_gettable failed');
>> }
>
> Um. This looks like you intend to work from C++ with Lua, compiled as C.
>
> In general, this is not a good idea.
Yep, I found that the hard way. That said I'd prefer the ability to
use prebuilt Lua libraries shipped as binary packages (for your
preferred distro). Is that a bad idea in general too? (Maybe yes
based on the amount of settings in luaconf.h... but I'm very new
around here!)
--
Julio Merino