[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Jumping out of a function without error semantics
- From: Noah Watkins <jayhawk@...>
- Date: Mon, 28 Jan 2013 12:34:41 -0800
On Jan 28, 2013, at 12:27 PM, Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br> wrote:
>> Is there a way to return back to lua_pcall with success from C?
>
> lua_error is the only way to abort a Lua transaction. However, note that
> you can use *any* Lua value a an error "message", and so you can signal
> success using a suitable Lua value. In any case, lua_pcall will fail,
> that is, will not return LUA_OK.
Thanks, this makes sense (we do something similar with a table on the stack prior to lua_error in the abort case).
Given that we use lua_error for our abort semantics, and probably soon to be our commit, too, is there a good programming pattern that can be used to ensure that Lua cannot 'fake' one of these calls using error(…), forcing them to always go through our interface? Would a piece of user data on the stack prior to lua_error do the trick?
-Noah