On 16.01.2018 22:03, aliak wrote:
On Friday, 12 January 2018 at 22:44:48 UTC, Timon Gehr wrote:
As promised [1], I have started setting up a DIP to improve tuple ergonomics in D:

https://github.com/tgehr/DIPs/blob/tuple-syntax/DIPs/DIP1xxx-tg.md
...


Oh Yes!

Question, would named tuples be able to be worked in or is that way out of scope? I.e. something for this use case:

alias Color = Tuple!(int, "r", int, "g", int, "b");
Color f(Color input);
auto color = f(Color(1, 2, 3));
writeln(color.r);

Very handy with general graphics stuff, Point, Vector, etc

Or for getting enumerate type functionality?
range.enumerate() // Tuple!(int, "index", T, "value)

So would we be able to work in something like:

(r: int, g: int, b: int) f(int r, int g, int b) {
     return (100, 200, 150);
}

// Or more consistent with function syntax?
(int r, int g, int b) f(int r, int g, int b) {
     return (100, 200, 150);
}

// And how about auto return named tuples?
auto f(int r, int g, int b) {
     return (r: 100, g: 200, z: 150);
}



My thoughts were:
http://forum.dlang.org/post/p3e4al$1jfc$1...@digitalmars.com

But as it has been requested more than once and it is a feature of existing Phobos tuples, I can add a proposal to the DIP that can be accepted/rejected independently, and add a few words to the "limitations" section.

Reply via email to