On Tuesday, 18 May 2021 at 19:34:45 UTC, Chris Piker wrote:
> So if I understand correctly, the idea is to get rid of AAs and replace them with moral equivalent of a Java HashMap. I'm guessing this means array index and assignment would become something like:
value = aa(key);
aa(key, value);
and AAs as a language construct would disappear. Or would the current syntax remain via CTFE?
D allows overloading the index operator, so you would still be able to write
value = aa[key];
aa[key] = value;
As far as I know the only thing D's operator overloading doesn't support that the built-in AA syntax does is insertion of values into nested AAs with a single assignment:
bool[string][string] aa; // NB: empty AA of AAs
aa["foo"]["bar"] = true; // assigns both aa["foo"] and aa["foo"]["bar"]
With a library type, you would instead have to write:
Map!(string, Map!(string, bool)) aa;
aa["foo"] = new Map!(string, bool);
aa["foo"]["bar"] = true;