FROM : James B. Tuley
DATE : Mon Apr 04 01:37:44 2005
On Apr 3, 2005, at 6:08 PM, Robert Chin wrote:
> On Apr 3, 2005, at 4:55 PM, James B. Tuley wrote:
>> On Apr 3, 2005, at 4:26 PM, Dietmar Planitzer wrote:
>>> Just because Sun has recently added generics to Java doesn't mean
>>> that it has suddenly turned into Ada or C++. Just like the addition
>>> of the reflection APIs to Java in version 1.2 hasn't turned it into
>>> ObjC or Smalltalk :)
>> Oh and generics would be pretty useful for objective-c from a
>> language aspect, then you wouldn't need to name things like
>> AddObject: AddInt: you could do Add<int>: Add<id>: and have your
>> primitives boxed, rather than using NSNumber in that instance or
>> NSValue, which gets really chunky looking in code.
>
> The main problem with adding generic support in Objective-C is that it
> would really slow the runtime down. VMs for languages like Java and C#
> do runtime type checking, whereas Objective-C has none of that
> overhead.
>
> There's no reason that NSNumber in its current form couldn't implement
> -add: (and corresponding -addFloat: -addInt: etc.) and other basic
> math operations using double dispatching. Generics support in
> Objective-C wouldn't really add any additional functionality -- it
> only exists in Java and C# to get around the runtime type checker in
> order to do Objective-C type things. And if what you need is runtime
> type checking, then one might as well just use Java.
I was talking about other classes, sorry I wasn't more specific. The
last thing i want to be doing is adding NSNumbers with some sort of
Add: syntax. AddObject: was a reference to a collection such as an
NSArray, to add an int to an NSArray you need to box it with an
NSNumber, and to do other primitives you use an NSValue, sure you could
implement a method AddInt: with a category but what about the next c
type you want to do and so on. It's just very lame, just like
AddObject: rather than Add:, yes we know it's an object, but it's
necessary because there are other things than Objects in Objective-C.
Generics for dealing with c types would allow object whose method is
being called to handle the boxing of the c type rather than the object
calling it. This is probably one of those things that is beyond the
limit of c superset, worse yet the idea behind it comes from wanting an
easier way of dealing with the c superset, it was just sort of a random
thought when Dietmar mentioned java and generics.
-Jay
DATE : Mon Apr 04 01:37:44 2005
On Apr 3, 2005, at 6:08 PM, Robert Chin wrote:
> On Apr 3, 2005, at 4:55 PM, James B. Tuley wrote:
>> On Apr 3, 2005, at 4:26 PM, Dietmar Planitzer wrote:
>>> Just because Sun has recently added generics to Java doesn't mean
>>> that it has suddenly turned into Ada or C++. Just like the addition
>>> of the reflection APIs to Java in version 1.2 hasn't turned it into
>>> ObjC or Smalltalk :)
>> Oh and generics would be pretty useful for objective-c from a
>> language aspect, then you wouldn't need to name things like
>> AddObject: AddInt: you could do Add<int>: Add<id>: and have your
>> primitives boxed, rather than using NSNumber in that instance or
>> NSValue, which gets really chunky looking in code.
>
> The main problem with adding generic support in Objective-C is that it
> would really slow the runtime down. VMs for languages like Java and C#
> do runtime type checking, whereas Objective-C has none of that
> overhead.
>
> There's no reason that NSNumber in its current form couldn't implement
> -add: (and corresponding -addFloat: -addInt: etc.) and other basic
> math operations using double dispatching. Generics support in
> Objective-C wouldn't really add any additional functionality -- it
> only exists in Java and C# to get around the runtime type checker in
> order to do Objective-C type things. And if what you need is runtime
> type checking, then one might as well just use Java.
I was talking about other classes, sorry I wasn't more specific. The
last thing i want to be doing is adding NSNumbers with some sort of
Add: syntax. AddObject: was a reference to a collection such as an
NSArray, to add an int to an NSArray you need to box it with an
NSNumber, and to do other primitives you use an NSValue, sure you could
implement a method AddInt: with a category but what about the next c
type you want to do and so on. It's just very lame, just like
AddObject: rather than Add:, yes we know it's an object, but it's
necessary because there are other things than Objects in Objective-C.
Generics for dealing with c types would allow object whose method is
being called to handle the boxing of the c type rather than the object
calling it. This is probably one of those things that is beyond the
limit of c superset, worse yet the idea behind it comes from wanting an
easier way of dealing with the c superset, it was just sort of a random
thought when Dietmar mentioned java and generics.
-Jay
| Related mails | Author | Date |
|---|---|---|
| No related mails found. | ||






Cocoa mail archive

