Bug 16458 – std.typecons.namedTuple

Status
RESOLVED
Resolution
WORKSFORME
Severity
enhancement
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-09-01T06:57:00Z
Last change time
2016-09-02T08:01:16Z
Assigned to
nobody
Creator
edder

Comments

Comment #0 by edder — 2016-09-01T06:57:54Z
Currently creating named tuples is a bit wordy: Tuple!(double, "x", double, "y")(1.0, 2.0); This could be simplified by adding a namedTuple function: namedTuple!("x", "y")(1.0, 2.0); I have an implementation in ggplotd (named aes [1]), which could be used if people think this is a good idea. [1] https://github.com/BlackEdder/ggplotd/blob/aes/source/ggplotd/aes.d#L82
Comment #1 by lodovico — 2016-09-01T21:06:47Z
We already have a function that does this in std.typecons: auto t = tuple!("x","y")(1.0,2.0); https://dlang.org/phobos/std_typecons.html#.tuple
Comment #2 by edder — 2016-09-02T08:01:16Z
Never even considered that tuple! might be able to do this. Sorry for the noise :)