• 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: "John C. Randolph" <email@hidden>
  • Date: Wed, 29 Aug 2001 13:11:05 -0700

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



I almost had a psychic girlfriend, but she left me before we met. -- Steven Wright


  • Follow-Ups:
    • Re: Inherited constructors
      • From: stuartbryson <email@hidden>
References: 
 >Inherited constructors (From: email@hidden)

  • Prev by Date: Re: Simple Cocoa Movie Player? QTVR Mouse Controller?
  • Next by Date: What Frameworks do I use?
  • Previous by thread: Inherited constructors
  • Next by thread: Re: Inherited constructors
  • Index(es):
    • Date
    • Thread