Skip navigation.
 
mlRe: Objective-C and it's future
FROM : Shawn Erickson
DATE : Sat Jul 08 04:22:20 2006

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

Related mailsAuthorDate
mlObjective-C and it's future Thomas Davie Jul 8, 01:33
mlRe: Objective-C and it's future Finlay Dobbie Jul 8, 01:46
mlRe: Objective-C and it's future Shawn Erickson Jul 8, 01:48
mlRe: Objective-C and it's future Charlton Wilbur Jul 8, 01:55
mlRe: Objective-C and it's future Thomas Davie Jul 8, 02:10
mlRe: Objective-C and it's future Robert Walker Jul 8, 02:12
mlRe: Re: Objective-C and it's future Shawn Erickson Jul 8, 02:22
mlRe: Objective-C and it's future Rob Ross Jul 8, 02:29
mlRe: Re: Objective-C and it's future Shawn Erickson Jul 8, 02:41
mlRe: Objective-C and it's future Thomas Davie Jul 8, 02:42
mlRe: Objective-C and it's future Erik Buck Jul 8, 02:50
mlRe: Objective-C and it's future Kenny Leung Jul 8, 02:57
mlRe: Objective-C and it's future Gregory Weston Jul 8, 03:00
mlRe: Objective-C and it's future Damien Sorresso Jul 8, 03:00
mlRe: Objective-C and it's future Damien Sorresso Jul 8, 03:00
mlRe: Re: Objective-C and it's future Shawn Erickson Jul 8, 03:07
mlRe: Objective-C and it's future Thomas Davie Jul 8, 03:12
mlRe: Objective-C and it's future Damien Sorresso Jul 8, 03:14
mlRe: Objective-C and it's future Rob Ross Jul 8, 03:15
mlRe: Objective-C and it's future Rob Ross Jul 8, 03:18
mlRe: Re: Objective-C and it's future Shawn Erickson Jul 8, 03:23
mlRe: Re: Objective-C and it's future Shawn Erickson Jul 8, 03:25
mlRe: Objective-C and it's future Thomas Davie Jul 8, 03:28
mlRe: Objective-C and it's future Thomas Davie Jul 8, 03:40
mlRe: Objective-C and it's future Sherm Pendley Jul 8, 03:54
mlRe: Objective-C and it's future Kenny Leung Jul 8, 03:56
mlRe: Objective-C and it's future Shawn Erickson Jul 8, 04:22
ml[Moderator] Re: Objective-C and it's future cocoa-dev-admins Jul 8, 04:56
mlRe: Objective-C and it's future Thomas Davie Jul 8, 13:10
mlRe: Objective-C and it's future listposter Jul 8, 17:02
mlRe: Objective-C and it's future cocoa-dev-admins Jul 8, 17:05
mlRe: Objective-C and it's future John C. Randolph Jul 8, 18:50
mlRe: Objective-C and it's future Ryan Stevens Jul 8, 19:13
mlRe: Objective-C and it's future Scott Thompson Jul 10, 16:21
mlRe: Objective-C and it's future Andrew Satori Jul 10, 16:43
ml[Modertator] Re: Objective-C and it's future cocoa-dev-admins Jul 10, 17:13