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

Mike Parker aldacron at gmail.com
Thu Feb 13 09:59:16 UTC 2020


On Thursday, 13 February 2020 at 09:56:27 UTC, Walter Bright 
wrote:
>
>> Would there be case where this type of initialization would 
>> mask the constructor of a type or vice versa?
>
> The constructor takes precedence.
>
>> struct S
>> {
>>      int a, b;
>>      this(int bp, int ap)
>>      {
>>          a = ap;
>>          b = bp;
>>      }
>> }
>> 
>> writing
>> 
>> S s = S(1, 2);
>> 
>> what would it pick?
>
> The constructor.

Which, for the record, is the current behavior. Unfortunately, 
the struct literal documentation only mentions opCall. I'll 
submit a PR.

https://dlang.org/spec/struct.html#struct-literal


More information about the Digitalmars-d mailing list