Automatic Inference for Both Key and Value Types of an Associative Array

Philippe Sigaud via Digitalmars-d digitalmars-d at puremagic.com
Fri Aug 15 04:41:01 PDT 2014


Kenji Hara:
> I implemented partial type deduction in AA keys.
> https://github.com/D-Programming-Language/dmd/pull/3615
>
> For example:
>     auto[auto[$]] aa5 = [[1,2]:1, [3,4]:2];
>     static assert(is(typeof(aa5) == int[int[2]]));
>
>     int[int[][$]] aa15 = [[[1],[2]]:1, [[3],[4]]:2];
>     static assert(is(typeof(aa15) == int[int[][2]]));

It's wonderful! I like it a lot.
As for Walter's question about the syntax, I quite like the [$]
thingie. '$' is already associated with 'length' in my mind.


More information about the Digitalmars-d mailing list