FROM : Rob Ross
DATE : Sat Jul 08 02:29:39 2006
On Jul 7, 2006, at 4:55 PM, Charlton Wilbur wrote:
>
> On Jul 7, 2006, at 7:33 PM, Thomas Davie wrote:
>
>> The most basic extension of the type system I can think of is to
>> allow something akin to generics, or ADTs to allow us to specify
>> such things as what type of object an array contains.
>
> Dynamic typing means you don't *need* Java-style generics or C++-
> style templates -- they are, after all, an attempt to give static
> typing the flexibility of dynamic typing. Java needs generics so
> that the compiler can determine what type an object is; Objective-C
> punts the decision to runtime. This is not a mistake, but an
> intentional design decision; the things that prevent you from doing
> stupid things often also prevent you from doing brilliant things.
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)?
So my understanding is you can have the best of both worlds. Or have
I misunderstood something?
Rob Ross
DATE : Sat Jul 08 02:29:39 2006
On Jul 7, 2006, at 4:55 PM, Charlton Wilbur wrote:
>
> On Jul 7, 2006, at 7:33 PM, Thomas Davie wrote:
>
>> The most basic extension of the type system I can think of is to
>> allow something akin to generics, or ADTs to allow us to specify
>> such things as what type of object an array contains.
>
> Dynamic typing means you don't *need* Java-style generics or C++-
> style templates -- they are, after all, an attempt to give static
> typing the flexibility of dynamic typing. Java needs generics so
> that the compiler can determine what type an object is; Objective-C
> punts the decision to runtime. This is not a mistake, but an
> intentional design decision; the things that prevent you from doing
> stupid things often also prevent you from doing brilliant things.
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)?
So my understanding is you can have the best of both worlds. Or have
I misunderstood something?
Rob Ross






Cocoa mail archive

