Re: Objective-C and it's future
Re: Objective-C and it's future
- Subject: Re: Objective-C and it's future
- From: Shawn Erickson <email@hidden>
- Date: Fri, 07 Jul 2006 19:22:20 -0700
On Jul 7, 2006, at 6:40 PM, Thomas Davie wrote:
On 8 Jul 2006, at 02:35, Jon Hendry wrote:
". So
what's against having this descriptive power in the language when
it's very useful for checking the correctness of the program. "
But how often do you run into problems because you didn't have
this kind of checking?
I don't think it ever happened to me in about 8 years of
professional Objective-C work.
Very often. 90% of the time I remove something from a container
class I get the compiler warning me that it might not respond to
the method I'm asking it to respond to, and have to make a cast,
that I know is type safe, but the compiler does not.
Humm... I seldom have to do any casting in my Objective-C code. You
have any code examples? (you may be fighting the system somehow)
Anyway try the following (it isn't meant to function at runtime).
Compile it with ClassOne, ClassTwo, and ClassThree commented out and
then with only ClassOne uncommented and see that the compiler just
needs to see that some object responds to the message you are sending.
Now uncomment only ClassOne and ClassTwo and see that the compiler
complains because it sees two different objects that have
someSelector but with different return types. A type cast would be
one way to fix this.
Now uncomment only ClassOne and ClassThree.
#import <Foundation/Foundation.h>
/*
@interface ClassOne {
}
- (float) someSelector;
@end
*/
/*
@interface ClassTwo {
}
- (double) someSelector;
@end
*/
/*
@interface ClassThree {
}
- (float) someSelector;
@end
*/
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
[[[NSArray array] objectAtIndex:0] someSelector];
[pool release];
return 0;
}
-Shawn
_______________________________________________
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