On Sunday, 31 July 2016 at 07:10:46 UTC, cym13 wrote:
The proposed change is litteraly just equivalent to the already
existing struct initialization, just made usable:
struct S {
int a;
int b;
}
auto s = S(b:42);
// equivalent to
S s = { b:42 };
Having the possibility to initialize structs without tying them
to a variable
proves useful when combined with functions that take this
struct but those
functions aren't directly impacted by the change.
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.