|
On 16-Oct-06, at 2:13 PM, Glenn Maynard wrote:
On Mon, Oct 16, 2006 at 02:00:11PM -0500, Rici Lake wrote:You only have to catch exceptions if they might be thrown. If you're not using exceptions, and you're using no c++ library which uses exceptions, then there's no problem, surely?The suggestion (and expected use, in the headers) is to make Lua a C++library that throws exceptions, instead of a C library that uses longjmp.
That would be the suggestion if you were using a C++ program with exceptions. If you're not, then Lua error handling with C++ is no different than Lua error handling with C: to wit, if you acquire resources and then use a Lua API which might throw a Lua error, you must use lua_pcall or lua_cpcall in order to trap the error so that you can release the resources. (Alternatively, you can make sure that the resources are part of a Lua userdata with an appropriate __gc metamethod.)