D's constructor call hierarchy (Was: Re: [Bug 91] Inherited classes require base class to have a default constructor.)

Daniel Keep daniel.keep.lists at gmail.com
Thu Apr 13 07:58:35 PDT 2006


> I've just answered myself. This design allows "one to hide superclass
> ctors", just like kris said, but only now did I get it. I guess that's
> the reason why the new languages have that behavior? Hum, what's it like
> in non-C-family OO languages like Ruby and Python, anyone knows ?

I could be wrong here, but since the "constructor" in Python is just a
specially named function (__init__), it should inherit.

Which makes things like, for example, writing new Exceptions stupidly
easy since you can do the equivalent of:

class MyExceptionThatDoesntDoMuch : Exception {}

And leave it at that.  Personally, I've always been fond of this
behaviour since it allows you to quickly customise the operation of a
particular class (bonus evil points for then *replacing* the original
class ^_^).

> (Also, DMD could print a better message when an inserted implicit
> super() is not found.)

Oh yeah, I've been bitten by that one.  "What do you mean there's no
valid constructor of zero arguments--I'm not trying to call one!  Which
line are you complaining about?!?!"

	-- Daniel

-- 

v1sw5+8Yhw5ln4+5pr6OFma8u6+7Lw4Tm6+7l6+7D
a2Xs3MSr2e4/6+7t4TNSMb6HTOp5en5g6RAHCP    http://hackerkey.com/



More information about the Digitalmars-d mailing list