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

Bruno Medeiros brunodomedeirosATgmail at SPAM.com
Thu Apr 13 12:06:32 PDT 2006


Daniel Keep wrote:
>> 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 ^_^).
> 

Well, in any case, in order to have that (constructor inheritance), we 
would either have to lose functionality (ability to hide superclass 
constructors) or devise a way to that (hide superclass constructors) in 
an opt-out way.


-- 
Bruno Medeiros - CS/E student
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D



More information about the Digitalmars-d mailing list