lua-users home
lua-l archive

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


2009/7/27 Juris Kalnins <juris@mt.lv>:
> On Mon, 27 Jul 2009 11:31:05 +0300, Jerome Vuarand
> <jerome.vuarand@gmail.com> wrote:
>
>> This would mean that all your C libraries would have to be modified to
>> take that flag into account and do special error handling.
>
> A good point, but would that really be required?
> If lua_State "locks down" and does nothing on most API calls, returns nil/0
> to every lua_topointer/touserdata, etc.
> then most of the C code wouldn't need to know about it, unless it uses Lua
> calls to do C side resource management.

For example lua_newuserdata is guaranteed to return a non-NULL
pointer. Therefore C code that use that API is unlikely to check the
validity of that pointer. Another example is lua_touserdata calls in a
userdata metamethod: the metamethod wouldn't be called if the first
argument was not a valid userdata, so the return pointer of
lua_touserdata won't be checked.

>> This
>> prevent using many (most?) existing binary modules, unless you patch
>> every one of them.
>
> If there are may external modules, that would be Bad, yes. But if Lua is
> simply an embedded extension language, then this is not an issue.

Of course if you write all C libraries yourself, that's not an issue.


2009/7/27 Juris Kalnins <juris@mt.lv>:
> On Mon, 27 Jul 2009 11:58:22 +0300, Ico <lua@zevv.nl> wrote:
>> Just curious, what is your reason for needing this ?
>
> g++ -fno-exceptions

Lua error mechanism only require setjmp/longjmp, not C++ exceptions.
Are you sure -fexceptions is needed for setjmp/longjmp to work ? IIRC
-fexceptions generate data needed for destructors to be called, which
setjmp/longjmp and thus Lua error mechanism do not need.