Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: gcc 3.3 try - catch -finally



On Thursday, Jun 26, 2003, at 21:50 US/Pacific, Chris Meyer wrote:

At WWDC during one of the sessions (410 - Cocoa Update, I think), the presenter mentioned a new Objective-C exception syntax in Cocoa using @try, @catch, and @finally.

Does anyone know if this available in the GCC 3.3 compiler? [sorry - I haven't installed the tools yet]

Yes, it's in the GM gcc 3.3 compiler.

If so, does it play nicely with existing exception macros (NS_DURING, NS_HANDLER, NS_ENDHANDLER)?

Yes!

Does it merge well with C++ exceptions (so as to make mixing of C++ and Objective-C possible)?

Unfortunately, no. The underlying mechanisms for C++ and ObjC exceptions are (at this point, at least) completely different and mutually incompatible. So, you should preferrably stick to one exception model or the other.


If not, is there a recommended migration path?

If you are currently using NS_{DURING, HANDLER, ENDHANDLER}, then the recommendation is to migrate that code to the new @try/@catch/@finally syntax. For the time being, it will remain binary compatible with the NS_{DURING, HANDLER, ENDHANDLER} machinery already being used by ObjC apps.

In "the future" (and I honestly don't know when/if that will be), when it is possible to break binary compatibility, then we would like to flip the switch to make the new @try/@catch/@finally constructs binary compatible with the C++ exception model instead, thus unifying the two. But that's way, way in the future, if it can happen at all.

However, regardless of what happens with C++ exception integration, the new syntax is definitely preferrable to the old macro style. It includes both @finally and @sychronized constructs, and automatically marks your local variables 'volatile' so that they are not clobbered when exceptions are thrown.

--Zem
--------------------------------------------------------------
Ziemowit Laski 1 Infinite Loop, MS 301-2K
Mac OS X Compiler Group Cupertino, CA USA 95014-2083
Apple Computer, Inc. +1.408.974.6229 Fax .5477
_______________________________________________
projectbuilder-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/projectbuilder-users
Do not post admin requests to the list. They will be ignored.

References: 
 >gcc 3.3 try - catch -finally (From: Chris Meyer <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.