Re: Inherited constructors
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