DIP32: Uniform tuple syntax

Timon Gehr timon.gehr at gmx.ch
Fri Mar 29 06:26:58 PDT 2013


On 03/29/2013 01:49 PM, Adam D. Ruppe wrote:
> My first thought when I saw {} was json. This is getting a little
> further away from tuples, but would it be hard to add named fields to
> this too like json:
>
> auto a = {"foo":12, "bar":"twelve"};
>
> int a_foo = a.foo;
> string a_bar = a[1];
>
>
> The std.typecons Tuple!() can do this kind of thing too.

Remove the quotes and it looks like a struct literal.

I think if named fields are allowed, it should look as follows:

auto a = {foo: 12, bar: "twelve"};



More information about the Digitalmars-d mailing list