Re: Objective C++ and ObjC exceptions
Re: Objective C++ and ObjC exceptions
- Subject: Re: Objective C++ and ObjC exceptions
- From: Thomas Engelmeier <email@hidden>
- Date: Sat, 22 Sep 2007 09:27:17 +0200
On 21.09.2007, at 21:35, Kai BrĂ¼ning wrote:
Well, you need to catch exceptions and either throw a C++ wrapper
exception or handle them before they exit a scope where you've
used RAII. A bit of a pain, perhaps...
[....]
... some substantial code ...
and have the compiler guarantee that the destructor of 'o' does the
release no matter what.
no. Use autorelease.
But than again, if I think about it, wrapping such calls in a catch
block is necessary in the above example anyway to do the release,
so maybe exception wrapping is a valid approach.
It is AFAIK the only under all circumstances working approach, which
brings me to my personal conclusion that Objective-C++ is only apt
for shallow interface layers as bracketing each language (Obj-C and C+
+) with approproate exception handlers is a PITA. IOW, it allows to
use C++ objects without adding an C interface layer. Note that that's
the standpoint for writing "correct" code and not "Umm, usually it
works, will add an fix/workaround when user reports errors" software.
One could, of course, use only nothrow() C++ methods or only handle
std::exception as a NSException does not mean "unwind transaction,
report and continue" but "Completely failed. Bad programmer. Fix your
code".
Regards,
Tom_E_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden