Revamping associative arrays

Max Samukha spambox at d-coding.com
Sat Oct 17 12:35:30 PDT 2009


On Sat, 17 Oct 2009 13:28:51 -0500, Andrei Alexandrescu
<SeeWebsiteForEmail at erdani.org> wrote:

>Associative arrays are today quite problematic because they don't offer 
>any true iteration. Furthermore, the .keys and .values properties create 
>new arrays, which is wasteful.
>
>Another issue with associative arrays is that ++a[k] is hacked, which 
>reflects a grave language limitation. That needs to be replaced with a 
>true facility.
>
>Any other issues with AAs that you want to see fixed, and ideas guiding 
>a redesign?
>
>
>Thanks,
>
>Andrei

They should be true reference types. Now we have oddities like this: 

int[int] a;
auto b = a;
a[1] =  2;
assert(b[1] == 2); // Range violation

int[int] a;
a[1] =  2;
auto b = a;
a[2] = 3;
assert(b[2] == 3); // Ok





More information about the Digitalmars-d mailing list