[DIP] In-place struct initialization

ZombineDev via Digitalmars-d digitalmars-d at puremagic.com
Wed Aug 3 14:35:58 PDT 2016


On Wednesday, 3 August 2016 at 20:30:07 UTC, deadalnix wrote:
> On Sunday, 31 July 2016 at 14:38:33 UTC, Lodovico Giaretta 
> wrote:
>> I support this idea of extending curly-brace initializers. It 
>> would be very useful and less ambiguous than parenthesized 
>> initializers.
>>
>
> Curly braces are already extremely overloaded. They can start a 
> block statement, a delegate literal, a struct literal and I'm 
> sure I forgot something.

Is there a better choice? StructInitializer [1] is already part 
of the grammar.
It would be inconsistent to use anything else, e.g.

S x = { a:1, b:2}; // already works
x = { a:3, b:4};   // why shouldn't this work?

[1]: http://dlang.org/spec/grammar.html#StructInitializer


More information about the Digitalmars-d mailing list