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