Tuple DIP
Timon Gehr
timon.gehr at gmx.ch
Sat Jan 13 23:21:57 UTC 2018
On 13.01.2018 23:57, Timothee Cour wrote:
> the DIP says this replace std.typecons.TypeTuple however no mention is
> made of named arguments, so I don't see how they could be a
> replacement (nor how would that allow for a migration path) without
> mentioning a word on this, eg:
>
> what would be the equivalent of this ?
> ` writeln(tuple!("x", "y", "z")(2, 3, 4).y); `
It would continue to work the same way.
I did consider adding a proposal for built-in named tuple syntax:
writeln((x: 2, y: 3, z: 4).y);
(int a, double b) t = (a: 1, b: 2.0);
int x = t.a;
double y = t.b;
But I decided against it to keep the DIP focused, and because of
potential future-proofing hazards related to named arguments. (For
Phobos tuples, name mismatches are simply ignored when converting one
named tuple into another, which I'm not sure is the best possible
behavior, but the goal of this DIP is not to fight this design.)
More information about the Digitalmars-d
mailing list