• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Objective-C and it's future
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
  • Follow-Ups:
    • [Moderator] Re: Objective-C and it's future
      • From: cocoa-dev-admins <email@hidden>
References: 
 >Re: Objective-C and it's future (From: Gregory Weston <email@hidden>)
 >Re: Objective-C and it's future (From: Thomas Davie <email@hidden>)
 >Re: Objective-C and it's future (From: Thomas Davie <email@hidden>)

  • Prev by Date: Are there any meetings around the New England area ?
  • Next by Date: Getting a bundle to load symbols from the main app bundle
  • Previous by thread: Re: Objective-C and it's future
  • Next by thread: [Moderator] Re: Objective-C and it's future
  • Index(es):
    • Date
    • Thread