• 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: Inherited constructors
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Inherited constructors


  • Subject: Re: Inherited constructors
  • From: stuartbryson <email@hidden>
  • Date: Fri, 31 Aug 2001 14:20:03 +1000

jcr,

On Thursday, August 30, 2001, at 06:11 AM, John C. Randolph wrote:

On Wednesday, August 29, 2001, at 11:43 AM, email@hidden wrote:

in general I find Obj-C extremely elegant and powerful, but I think it would be better if constructors were not inherited.

Well, it's a good thing that Obj-C doesn't *have* constructors. In obj-c, there are no magic wands getting waved and executing code just because something came into scope.

Now, if as you recommend, +alloc and -init weren't inherited, I'd have to write a hell of a lot more code, and I shudder to think of the nightmare of how the compiler is supposed to know that -init, -initWithFrame:, -initWithCoder: and -initWithSomethingElse: are all constructors and shouldn't get inherited!

The situation you describe of your designated initializer not getting called because you didn't override -init is simple enough to deal with, without introducing some truly horrendous hacks in the compiler.

-jcr

Thats true... imagine trying to rewrite the NSObject init method?

Stuart


References: 
 >Re: Inherited constructors (From: "John C. Randolph" <email@hidden>)

  • Prev by Date: Re: Abstract classes and methods
  • Next by Date: speed daemons
  • Previous by thread: Re: Inherited constructors
  • Next by thread: Re: Inherited constructors
  • Index(es):
    • Date
    • Thread