Re: To @try or not?
Re: To @try or not?
- Subject: Re: To @try or not?
- From: Alex Perez <email@hidden>
- Date: Fri, 8 Oct 2004 10:16:06 -0700 (PDT)
On Fri, 8 Oct 2004, James Bucanek wrote:
>
Greetings,
>
>
I'm a fairly new Cocoa/Obj-C programmer.
>
>
I was just about to start writing @synchronized and @try/@catch blocks when I read this in the documentation:
>
>
Note: Using either of these features in a program, renders the application
>
runnable only in Mac OS X v10.3 and later because runtime support for exception
>
handling and synchronization is not present in earlier versions of the software.
Since I haven't seen anyone else respond to this yet, here's my take on it:
>
I have it in the back of my mind that the program I'm writing should run under 10.2 as well. So, here are my questions:
>
>
(1) Are there alternative exception handling and thread synchronization techniques or libraries that will work in 10.2 and later? I saw a reference in the gcc 3.3 release notes to NSException and NS_DURING/NS_HANDLER. Are these the standard pre 10.3 exception constructs? Are there any significant advantages to using @try over NS_DURING?
The NS_ macros will work with any version of OS X. They've been around
since the NeXT (LaST? Hah, I made a funny!) days. It's theoretically
possible, since the NS_* macros are just that, macros, to make them
actually use @try and @catch internally. This is what GNUstep does if it's
compiled under a version of GCC which supports these compiler directives.
Note that, using exception handling for regular flow control is considered
bad style. You might get away with that in Java or even C++ but it's
really shunned (even by Apple themselves, and rightfully so) for
general-use.
>
(2) If I start writing code using @try/@catch and @synchronized, how difficult will it be to retrofit that code so it will work in 10.2?
Difficult? probably not. Tedious? probably.
You could always whip up some custom macros that used NS_* under 10.2 and
@try and friends under 10.3 and later.
Cheers,
Alex Perez
GNUstep.org Portaholic
GNUstep.org web co-maintainer.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden