Nicer syntax for constructors

dayllenger dayllenger at protonmail.com
Mon Nov 19 06:16:46 UTC 2018


On Sunday, 18 November 2018 at 19:59:27 UTC, Timon Gehr wrote:
> class C{
>     string a;
>     int b;
>     char c;
>     float d;
>     uint e;
>     bool f;
>     this(string a, int b, char c, float d, uint e, bool f){
>         mixin(assignFields);
>     }
> }

It is not good when there is one parameter, you probably will 
write usual assignment for readability. In most of cases - 1 or 2 
parameters - this solution improves nothing.

On the other hand, members with _ or m_ in the name will force 
parameters to have the same names in the OP syntax.


More information about the Digitalmars-d mailing list