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

Steven Schveighoffer schveiguy at gmail.com
Thu Feb 13 13:23:29 UTC 2020


This DIP, nor the prerequisite DIP 1030, mention that structs will have 
a default literal syntax that allows named parameters when a constructor 
is absent.

DIP 1030 specifically mentions only function and template parameters.

DIP 1031 hints that DIP 1030 must be accepted, so therefore it must have 
some bearing on this. However, one might interpret that to mean you have 
to define a constructor to get named parameter syntax (which, if true, 
would be a huge breaking change that needs to be mentioned). Also, the 
single example does not involve named parameters whatsoever.

It needs to be made clear that one can use an equivalent syntax to 
initialize a struct that could previously use an initializer. I'm 
assuming this is the case, and if not, I would reject this DIP.

e.g. "Struct literals will be modified to allow named parameters, which 
follow the spec of DIP 1030. Any parameter not provided will receive a 
default value according to the .init value of the struct."

And a more definitive example:

struct S
{
    int a;
    int b;
}

S s = {b: 5}; // Deprecated, use S(b: 5) instead

-Steve


More information about the Digitalmars-d mailing list