Re: Objective-C++ Exceptions (was: PICT control problems)
Re: Objective-C++ Exceptions (was: PICT control problems)
- Subject: Re: Objective-C++ Exceptions (was: PICT control problems)
- From: Marshall Clow <email@hidden>
- Date: Sat, 24 Jun 2006 11:38:48 -0700
At 12:58 PM -0500 6/24/06, Bill Bumgarner wrote:
On Jun 24, 2006, at 11:22 AM, Steve Sisak wrote:
On Jun 24, 2006, at 10:36 AM, Marshall Clow wrote:
At 10:28 AM -0500 6/24/06, Bill Bumgarner wrote:
Objective-C is trivial to learn for a C programmer. And you can
use C++ in Objective-C apps just fine.
[ For the non-metaphorically minded - Objective C and C++ have
different exception models, and they don't play well together at
all ]
If your own code throws NSExceptions as a part of execution to
indicate user error, then your architecture is fighting against
the grain of Cocoa and I would suggest that <...> you reconsider
the architecture of your app.
Let me make Marshall's point al little clearer for you:
Objective-C exceptions don't call the destructors of stack based
objects as the stack unwinds.
C++ exceptions don't respect Objective-C's conventions either.
Also, there's lots of people here who write things that aren't
applications or who use 3rd party libraries or extant open source
code that already have an existing model.
I fully understand the impedance mismatch between Obj-C exceptions
and C++ exceptions and I'm not trying to diminish the problem.
Then you agree that your statement "you can use C++ in Objective-C
apps just fine" was, at best,
misleading.
If your application encounters an NSException, then the state of the
AppKit, Foundation, and CoreData are undefined. NSExceptions are
thrown for non-recoverable runtime errors.
And, yes, as you indicate this becomes a much bigger problem when
you are working with a third party framework or library whose design
pattern goes against this model of
exceptions-only-indicate-runtime-nonrecoverable-errors.
Such as the C++ standard runtime library.
[ Which, IMHO, does not qualify as "a third party framework or library" ]
However, these same frameworks are also going to cause heck if they
toss an exception that gets thrown across frames of execution
sourced from Foundation, AppKit, CoreData or other Apple frameworks.
I completely agree with this statement.
--
-- Marshall
Marshall Clow Idio Software <mailto:email@hidden>
It is by caffeine alone I set my mind in motion.
It is by the beans of Java that thoughts acquire speed,
the hands acquire shaking, the shaking becomes a warning.
It is by caffeine alone I set my mind in motion.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden