• 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: Why can't I name a property `tag'?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why can't I name a property `tag'?


  • Subject: Re: Why can't I name a property `tag'?
  • From: Jens Alfke <email@hidden>
  • Date: Thu, 10 Jul 2008 08:40:53 -0700


On 10 Jul '08, at 8:19 AM, an0 wrote:

However, if you don't know what exact type of Cocoa I am, how could
you call me BlackCocoa so surely?

Can we stop using confusing metaphors and just talk about OOP? :-p

When the compiler parses a message-send expression ("[....]") it tries to figure out which declared method is being invoked. The most important reason for this is that it needs to know the return type of the method, because that can affect the machine code that's generated for the call.

If the receiver of the expression is typed as "id", i.e. with no class, the compiler has no clues about what class to look for matching methods in. So it looks in any @interface blocks that it's already seen (i.e. ones in all #imported headers). If it finds one matching method, it uses it. If it finds more than one method, and the return types differ, then the situation is ambiguous … so it emits a warning.

The short answer to your question, then, is that the compiler has to decide what method is being used, because that determines what machine code to generate. This is an ugly side effect of the fact that Objective-C compiles into native code and not some abstract bytecode like Java or Python. It's part of the price you pay as a developer for creating apps that run fast.

—Jens

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Why can't I name a property `tag'?
      • From: an0 <email@hidden>
    • Re: Why can't I name a property `tag'?
      • From: Graham Cox <email@hidden>
References: 
 >Why can't I name a property `tag'? (From: an0 <email@hidden>)
 >Re: Why can't I name a property `tag'? (From: Graham Cox <email@hidden>)
 >Re: Why can't I name a property `tag'? (From: an0 <email@hidden>)
 >Re: Why can't I name a property `tag'? (From: "I. Savant" <email@hidden>)
 >Re: Why can't I name a property `tag'? (From: an0 <email@hidden>)
 >Re: Why can't I name a property `tag'? (From: Jean-Daniel Dupas <email@hidden>)
 >Re: Why can't I name a property `tag'? (From: an0 <email@hidden>)

  • Prev by Date: Drawing issues in custom view
  • Next by Date: Re: Why can't I name a property `tag'?
  • Previous by thread: Re: Why can't I name a property `tag'?
  • Next by thread: Re: Why can't I name a property `tag'?
  • Index(es):
    • Date
    • Thread