inheriting constructos

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sun Nov 29 16:18:27 PST 2009


Denis Koroskin wrote:
> On Mon, 30 Nov 2009 02:20:40 +0300, bearophile 
> <bearophileHUGS at lycos.com> wrote:
> 
>> Andrei Alexandrescu:
>>> c) If a class doesn't define any constructors but does add at least a
>>> non-static field -> undecided.
>>
>> Does 'undecided' mean 'compile-time error'?"
>>
>> Bye,
>> bearophile
> 
> I think it means they are not decided whether it should inherit 
> constructors.
> 
> Back on topic, I do think inheriting constructors is a good idea, even 
> in presence of additional fields (why not?)
> 
> I also think constructor inheritance could be implemented without any 
> changes to the language the following way:
> 
> this(Args...)(Args args) if (__traits(compiles, super(args)))
> {
>     super(args);
> 
>     // initialize additional fields, if any present
>     // and/or do some post-construction logic
> }
> 
> Why create new rules? :)

Alas, that doesn't work because of ref and out arguments. I actually 
think it's a language bug that it's impossible to implement perfect 
forwarding.

Andrei



More information about the Digitalmars-d mailing list