[DIP] In-place struct initialization

Lodovico Giaretta via Digitalmars-d digitalmars-d at puremagic.com
Sun Jul 31 07:38:33 PDT 2016


On Sunday, 31 July 2016 at 13:39:58 UTC, Enamex wrote:
> I suggest extending the existing `S s = {field: value}` syntax 
> to allow specifying the type itself next to the field list and 
> make it usable generally everywhere.
>
> So, instead:
>
> takeThing(Thing{ field: val, num: 43 });
>
> It shouldn't clash with anything else, I think.

I support this idea of extending curly-brace initializers. It 
would be very useful and less ambiguous than parenthesized 
initializers.

[A thread about this]
http://forum.dlang.org/post/ni0u47$2100$1@digitalmars.com

[An issue about this]
https://issues.dlang.org/show_bug.cgi?id=15692


More information about the Digitalmars-d mailing list