Re: Future Objective-C changes
Re: Future Objective-C changes
- Subject: Re: Future Objective-C changes
- From: Chris Meyer <email@hidden>
- Date: Wed, 21 May 2003 08:39:14 -0700
Regardless of it's merit, it's a common C++ idiom for writing
exception safe code.
Obviously, and I understand the reasoning that leads to such a
solution. I even thought it was a Good Thing, initially. It took me
a while to realize just how much of a coding horror it is. Which in
turn taught me something about the techie mind-set (including my own),
something to be wary of in the future.
Most C++ programmers will find this quite natural.
Yes. Does this say something about the construct or about C++
programmers? ;-)
Let's not go too overboard here. Bottom line is that classes like that
saved countless tons of hours in programming time. To be honest I've
never been comfortable with a global graphics context anyway, rather
preferring to pass around a pointer to the drawing context -- so I can
understand your view on these types of classes. The real gain in C++
was in using smart pointers which I think you would find much more
difficult to argue against...
Of course, in an Obj-C world now where such idiom looks rather
unnatural, since there is no stack based objects. This is one reason
I never liked Obj-C++ to begin with, it just confuses both Obj-C and
C++ folks.
I think Obj-C++ is good if you have an existing C++ code-base that you
need to hook up to Objective-C. I think you are right that apart from
that very well defined area it is not such a good idea.
In any case, if Objective-C++ is to be useful, it needs to integrate
the exception mechanisms. When I've been faced with similar problems in
the past I've had to build a brick wall between libraries where
exceptions reverted to some other mechanism. So:
NS_TRY
try
CallCPlusPlusMethod();
catch ( ... )
transmute_cpp_exception_to_OC_exception
NS_HANDLER
...
NS_ENDHANDLER
Yuk! This is painful at best and error prone and wrong more likely.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.