• 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: Re: Objective-C and it's future
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Re: Objective-C and it's future


  • Subject: Re: Re: Objective-C and it's future
  • From: "Shawn Erickson" <email@hidden>
  • Date: Fri, 7 Jul 2006 18:07:32 -0700

On 7/7/06, Damien Sorresso <email@hidden> wrote:
On 7 Jul, 2006, at 7:29 PM, Rob Ross wrote:

> I'm just learning Obj-C myself, so maybe my understanding is not
> correct. But, don't you actually have the option to use static
> typing in certain instances, and use dynamic typing in others?
>
> Eg:
>
> id    myStr;
>
> vs
>
> NSString *myStr;
>
>
> Won't the second version give you the benefits of static typing
> (compiler time checking)?
>

Well, kinda sorta. The compiler will check, but the messages are
still bound at runtime. For example, this statement won't even
generate a warning.

NSString *str = [[NSData alloc] init];

because both `NSData' and `NSString' have `init' methods, and `init'
methods return an object of type `id', which is NOT statically typed.

...but the point is you could implement classes that are specific about what they return (I often do that with my init methods) and the compiler would flag this for you.

So in many ways you can provide type information and get type related
warnings flagged by the compiler (in no way enforced at runtime of
course).

-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:
    • Re: Objective-C and it's future
      • From: Damien Sorresso <email@hidden>
    • Re: Objective-C and it's future
      • From: Rob Ross <email@hidden>
References: 
 >Re: Objective-C and it's future (From: Damien Sorresso <email@hidden>)

  • Prev by Date: Re: Objective-C and it's future
  • Next by Date: Re: Objective-C and it's future
  • Previous by thread: Re: Objective-C and it's future
  • Next by thread: Re: Objective-C and it's future
  • Index(es):
    • Date
    • Thread