DIP 1031--Deprecate Brace-Style Struct Initializers--Community Review Round 1 Discussion

IGotD- nise at nise.com
Thu Feb 13 09:47:13 UTC 2020


According to the DIP

This will be deprecated.

struct S { int a, b; }

S s = { 1, 2 }; // Deprecated: use S(1, 2) instead


So after this DIP we would write

S s = S(1, 2);

instead.

However, would

S s = (1, 2);

be allowed inferring the type?


Would there be case where this type of initialization would mask 
the constructor of a type or vice versa?

Ex.

struct S
{
     int a, b;
     this(int bp, int ap)
     {
         a = ap;
         b = bp;
     }
}

writing

S s = S(1, 2);

what would it pick?



More information about the Digitalmars-d mailing list