• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Objective-C++ Exceptions (was: PICT control problems)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Objective-C++ Exceptions (was: PICT control problems)


  • Subject: Re: Objective-C++ Exceptions (was: PICT control problems)
  • From: Bill Bumgarner <email@hidden>
  • Date: Sat, 24 Jun 2006 12:58:31 -0500

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.


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. 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'm not discounting the problem. Not in the least. I am trying to draw attention to a different dimension of the problem that, unless acknowledged and addressed, will lead to code that doesn't work no matter how "normalized" the Obj-C vs. C++ exception handling might be.

b.bum
_______________________________________________
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


  • Follow-Ups:
    • Re: Objective-C++ Exceptions (was: PICT control problems)
      • From: Thomas Engelmeier <email@hidden>
    • Re: Objective-C++ Exceptions (was: PICT control problems)
      • From: David Dunham <email@hidden>
    • Re: Objective-C++ Exceptions (was: PICT control problems)
      • From: Marshall Clow <email@hidden>
References: 
 >PICT control problems (From: John Lunt <email@hidden>)
 >Re: PICT control problems [SOLVED] (From: John Lunt <email@hidden>)
 >Re: PICT control problems [SOLVED] (From: Scott Thompson <email@hidden>)
 >Re: PICT control problems [SOLVED] (From: John Lunt <email@hidden>)
 >Re: PICT control problems [SOLVED] (From: Markus Hitter <email@hidden>)
 >Re: PICT control problems [SOLVED] (From: John Lunt <email@hidden>)
 >Re: PICT control problems [SOLVED] (From: Bill Bumgarner <email@hidden>)
 >Re: PICT control problems [SOLVED] (From: Marshall Clow <email@hidden>)
 >Re: PICT control problems [SOLVED] (From: Bill Bumgarner <email@hidden>)
 >Objective-C++ Exceptions (was: PICT control problems) (From: Steve Sisak <email@hidden>)

  • Prev by Date: Re: can I catch an EXC_BAD_ACCESS?
  • Next by Date: Re: Objective-C++ Exceptions (was: PICT control problems)
  • Previous by thread: Objective-C++ Exceptions (was: PICT control problems)
  • Next by thread: Re: Objective-C++ Exceptions (was: PICT control problems)
  • Index(es):
    • Date
    • Thread