[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: customizable Lua "panic" behavior
- From: "Jim Mathies" <jamesmathies@...>
- Date: Mon, 19 Nov 2001 23:03:27 -0600
Do you remove the exit call with this? or are you saying it will never
be called? I can understand trapping exceptions, but if an exception
occurs, your Lua mem really may be totally hosed. Calling lua_close()
would have unpredictable results. Maybe i'm not following you here...
Regards,
Jim
| This is the only solution I've actually liked thus far. It is easy to
| envision something like:
|
| void RunMain()
| {
| try
| {
| // All app code that would've been in main() goes here.
| }
| catch(...)
| {
| }
| }
|
| static int StartExecution(lua_State *L)
| {
| RunMain();
| return 0;
| }
|
| int main()
| {
| lua_pushcfunction(L, StartExecution);
| lua_call(0,0);
| }
|
| In a way, this is like a C++ exception handler (also illustrated above).
| The lua_call() acts just like a C++ try-catch block, except for Lua
| code.
|
| Because of this thread popping up over and over, a FAQ should be added
| to the Lua documentation...
|
| Josh