Anonymous classes should pass through super ctors

Steven Schveighoffer schveiguy at yahoo.com
Mon Aug 18 11:18:48 PDT 2008


"BCS" wrote
> Reply to Bruno,
>
>> I don't see how this could be dangerous in any way whatsoever, if the
>> ctor inheritance rules followed the same rules as method inheritance
>> rules:
>> * if you don't override or overload any ctor in the overload set, then
>> the whole overload set is available in the child class.
>> * if you do override or overload any ctor, well... follow the same
>> rules
>> as overriding/overloading a method.
>
>
> There needs to be an easy way to forbid one, several or all base 
> constructors.

If you want to forbid all constructors, make a private constructor in the 
derived class.  Due to the scope resolution rules of D, only the most 
derived class' counts, unless you alias the parent's.

If you want to forbid one, then you have to forbid it the same way you do 
normal methods, implement all the ones you don't want to forbid.

Yes, this is a pain, but it is consistent.  If Walter wants to add a way to 
selectively alias in base methods, then use that way, but it needs to be 
consistent.

> And while were at it, it would be nice to add an auto constructor that is 
> added to all constrictors (kind of like member variable initialization in 
> c#)

It would be nice to be able to do this with runtime constructs, instead of 
being limited to compile-time ones.

-Steve 





More information about the Digitalmars-d mailing list