lua-users home
lua-l archive

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


On Mon, Nov 10, 2014 at 11:20 AM, Jan Behrens
<jbe-lua-l@public-software-group.org> wrote:
> I do use lua_pcall when calling user code. I just found it easier to
> use lua_atpanic when preparing the Lua machine (calling luaL_openlibs,
> creating objects that are passed to the user code, etc). If I do not
> use lua_atpanic at all, then I'd have to wrap my whole program in yet
> another function, e.g. instead of writing...
>
> L = lua_newstate(my_allocator, NULL);
> lua_atpanic(L, my_panic_handler);
> luaL_openlibs(L);
>
> ...i'd already have to encapsulate luaL_openlibs(L) in another
> (pcall'ed) function. This makes my code less readable. So I like the
> interface that lua_atpanic offers me.

Uh, what? You have to write a panic handler, why not just remove the
panic handler completely and instead write a wrapper function. I don't
see how the panic interface is more convenient when you have to
longjmp out of it to avoid Lua calling abort().

-- 
Patrick Donnelly