[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: try..catch in Lua
- From: James Porter <porterj@...>
- Date: Tue, 29 Jan 2008 01:49:31 -0600
Hu Qiwei wrote:
Traditional pcall() and xpcall() behavior is intact. You can nest
pcall() and try..catch as you want.
The difference is, you can call coroutine.yield() (or lua_yield in C)
in try..catch block. The implementation
is platform independent. It uses setjmp...longjmp mechanism so it may
not be quite compatible with
A while back, I made a patch to Lua to implement full C++ exception
handling, primarily to ensure that exceptions passing through the Lua
state don't put it in an inconsistent, well, state. At the time, I
designed it to catch std::exceptions in pcalls and turn them into Lua
errors, but I think it would be preferable to have try/catch available
for things like that.
I'm not sure how likely it is that my exception-handling changes will
get rolled into Lua proper, but I think these two patches would benefit
from being merged into a single, more thorough patch.
If there's interest, I'll post my patch again, though I want to make a
few small changes to it first.