Helge Hess <email@hidden> wrote:
> Wouldn't it be nice to do a:
> int a = [myArray objectAtIndex:0];
> and get the object stored in the NSArray sent an -intValue? Yes, we
> could invent a new language for this, but I don't think its necessary
> in practice and would be quite a waste of time.
Well it's kind of nice except that the compiler can't know that the
objects in the collection implement intValue. So that line would have
to compile without warnings and possibly throw an exception when
intValue is called on an object that doesn't support it during run
time. I like Objective-C for how explicit it is compared to C++. You'd
also need to add other implicit type conversion like float, double,
long long, etc. And what do you do with:
char *nullTerminatedString = myStringObject;
C String encoding? UTF8? Obviously it can all be worked out and
properly documented and isn't much more than some additional syntactic
sugar on the language but being explicit about such things is nice.
It's the explicit nature of reference counting I like too. Not that GC
doesn't have it's place, I just don't think it fits Objective-C very
well. If GC did make it into Objective-C I'd like it be explicit as to
what it applied to:
NSString *myString; // ref counted
NSString ^myCollectedString;
That way old code works the same and the compiler can forbid pointer
obfustication to NSString^ pointers.
I would love to see things like @3.14f creating an initialized
NSNumber instance though using the same mechanism @"blah" uses. ie:
the class created is configurable in the compiler. Adding a keyword or
two to delcare that instance variables should get compiler generated
"best-practices" accessors would also be nice. Obviously writing your
own accessors would override whatever the compiler came up with.
Anyway, it's been a fascinating debate so far.
Take care,
Guy
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Objc-language mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden