Re: red black trees
Re: red black trees
- Subject: Re: red black trees
- From: Ethan John <email@hidden>
- Date: Tue, 24 Feb 2004 23:18:26 -0800
I don't understand either one of you: If you want to use C++ inside an
Objective-C program, go right ahead. No one is stopping you. Just be
sure you confine your C++ ramblings to single functions or classes to
maintain a decent level of consistency.
On Feb 24, 2004, at 10:46 PM, Allan Odgaard wrote:
On 25. Feb 2004, at 5:41, Todd Blanchard wrote:
Not to be picky, but your Objective C examples are all examples of
terrible Objective C.
[...]
Are you not exaggerating a bit? The compare: is from the Cocoa API.
To not use the var-args array constructor but adding the elements
one-by-one was a) because they may be unknown at construction time and
b) the point of that example was to show that it takes ~9 lines to
introduce even the simplest type (which you removed from yours) and
similarly long constructs to create instances -- I could have used
NSNumber instead of my type, but often in algorithmic programming
(which was the topic) you need to introduce your own (simple) types!
and I could have added a similar (numberWithInt:) class method which
use the autorelease pool for easier construction, but that is still
not even close to C++'s stack-allocation and/or implicit construction
from another type (and it has run-time overhead which you often cannot
afford in algorithmic programming).
The add: I agree was stupid -- my intent here was really closer to
append, like this:
NSMutableString* str = [NSMutableString string];
for(int i = 0; i < 10; i++)
{
unichar ch = next_char();
NSString* tmp = [NSString alloc] initWithBytes:&ch length:1];
[str appendString:tmp];
[tmp release]; // no release pool because we are in a loop
}
Compared to:
vector<unichar> v;
generate_n(back_inserter(v), 10, next_char);
Or (w/o using a standard algorithm):
wstring str;
for(int i = 0; i < 10; i++)
str += next_char();
You may find other ways to achieve the same in ObjC, and you may argue
that it is an unnatural example, but I do not think it changes my
original point: that ObjC is really bad at algorithmic programming
because of the amount of syntactic overhead.
_______________________________________________
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.
ethan john
Apple Campus Representative
University of Washington
http://students.washington.edu/thaen/
206.841.4157
"I'm exactly twelve times holier than I used to be."
_______________________________________________
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.