Time to kill T() as (sometimes) working T.init alias ?

Timon Gehr timon.gehr at gmx.ch
Sun Nov 25 09:25:08 PST 2012


On 11/25/2012 05:47 PM, Dmitry Olshansky wrote:
> After killing this ugly craft the suggestion is to, of course, introduce 0-argument constructors.

I think it should be done, but then it is even less clear how .init 
should work.

>  static opCall can't prevent introduction of 0-arg constructor as the compiler already has to disambiguate between the static opCall and the ctor. (BTW which one wins?)

It does not disambiguate.

I think constructors and static opCall should just overload against each 
other,

The current behaviour in case there are both opCall and constructors is 
to attempt to pick opCall in case the number of arguments is zero and 
the constructors otherwise.


> ...
>
> Thoughts?
>

1. is valid.
2./3. are examples of insufficient template constraints.

If the suggestion is to get rid of the built-in struct 0-arg default 
constructor iff the user provides his own constructors, as is done with 
the more than 0-arg default constructors, then I fully agree.


More information about the Digitalmars-d mailing list