On Fri, Jun 6, 2008 at 6:26 AM, Graham Cox <[EMAIL PROTECTED]> wrote:

> I guess the question is, given an object type 'id', which method signature
> will the compiler go with? Does the return type affect the method signature?
> (In C++ it doesn't for example), so two methods:
>
> - (CGPoint) position;
> - (float)   position;
>
> might well have identical signatures. The compiler doesn't have an object
> type to narrow it down, so which will it use - the first it finds maybe.

I'd have thought that in the case:

// id anonymous
float f = [anonymous position];

the compiler ought to assume that the method being used is the one
returning a float, or if not at least warn about an implicit cast from
CGPoint to float. Perhaps if it were -(int)position rather than
-(CGPoint)position, you might not expect a warning, but in that case
you would expect a cast, so it shouldn't break.

However, that does appear to be what is happening. In the absence of
any other explanation, I'd call it a compiler bug.

Hamish
_______________________________________________

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 [EMAIL PROTECTED]

Reply via email to