On or about 4/26/10 1:22 PM, thus spake "Greg Parker" <gpar...@apple.com>:

> The compiler warns more aggressively for mismatches that do affect the call
> site's code. Those are more likely to be actual bugs, rather than correct but
> loosely-typed code. For example, if you change your example's parameter types
> to NSString* vs int, you'll get the warning even without any extra warning
> flags.

Just to clarify: you get the warning, but only when you try to *call* the
method that has multiple definitions (and then only when using dynamic
typing, of course).

In other words, this code by itself does not generate any warning:

@interface MyClass : NSObject {
}
- (void) tryme: (NSString*) s;
@end

@implementation MyClass
- (void) tryme: (NSString*) s {
    ;
}
@end
@interface MyClass2 : NSObject {
}
- (void) tryme: (int) s;
@end
@implementation MyClass2
- (void) tryme: (int) s {
    ;
}
@end

I guess I was hoping and expecting that the above would be sufficient to
generate a warning ("hey, you've defined methods with the same name but
different signatures; this could lead to trouble"). But the compiler is
silent. 

I see now, however, *why* the compiler is silent: it's because it weren't,
it would be too chatty. I turned on -Wselector and got 114 warnings... :)

m.

-- 
matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/
pantes anthropoi tou eidenai oregontai phusei
Among the 2007 MacTech Top 25, http://tinyurl.com/2rh4pf
AppleScript: the Definitive Guide, 2nd edition
http://www.tidbits.com/matt/default.html#applescriptthings
Take Control of Exploring & Customizing Snow Leopard
http://tinyurl.com/kufyy8
RubyFrontier! http://www.apeth.com/RubyFrontierDocs/default.html
TidBITS, Mac news and reviews since 1990, http://www.tidbits.com



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to