DIP32: Uniform tuple syntax
kenji hara
k.hara.pg at gmail.com
Fri Mar 29 07:57:19 PDT 2013
For tuple values with named fields, we need more thoughts about semantics.
alias MyPair = typeof({1, "hi"});
alias MyRecord = typeof({count:1, msg:"hi"});
static assert(is(MyPair == MyRecord)); // true or false?
static assert(is(MyPair : MyRecord)); // true or false?
static assert(is(MyRecord : MyPair)); // true or false?
alias MyStudent = typeof({num:1, name:"John"});
static assert(is(MyRecord == MyStudent)); // true or false?
Kenji Hara
2013/3/29 Adam D. Ruppe <destructionator at gmail.com>
> 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.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20130329/769e0de3/attachment.html>
More information about the Digitalmars-d
mailing list