• 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: AGC was: Re: inner classes not possible,(in objc) right?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AGC was: Re: inner classes not possible,(in objc) right?


  • Subject: Re: AGC was: Re: inner classes not possible,(in objc) right?
  • From: "James B. Tuley" <email@hidden>
  • Date: Sun, 3 Apr 2005 18:37:44 -0500


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

_______________________________________________
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: AGC was: Re: inner classes not possible,(in objc) right?
      • From: "James B. Tuley" <email@hidden>
  • Prev by Date: Re: dateWithNaturalLanguageString problems
  • Next by Date: Re: AGC was: Re: inner classes not possible,(in objc) right?
  • Previous by thread: ANN: Emacs on Aqua 8.0-rc2
  • Next by thread: Re: AGC was: Re: inner classes not possible,(in objc) right?
  • Index(es):
    • Date
    • Thread