Associative arrays

Imperatorn johan_forsberg_86 at hotmail.com
Tue May 18 20:33:24 UTC 2021


On Tuesday, 18 May 2021 at 19:34:45 UTC, Chris Piker wrote:
> On Tuesday, 18 May 2021 at 13:25:32 UTC, Paul Backus wrote:
>> On Tuesday, 18 May 2021 at 09:14:46 UTC, Chris Piker wrote:
>>> What would the library equivalent of this:
>>>
>>> ```d
>>> long[string] aa = ["foo": 5, "bar": 10, "baz": 2000 ];
>>> ```
>>>
>>> look like?
>>
>> Something like this, most likely:
>>
>> ```d
>> auto aa = makeAA!(string, long)("foo", 5, "bar", 10, "baz", 
>> 2000);
>> ```
>
> 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:
>
> ```d
>    value = aa(key);
>    aa(key, value);
> ```
> and AAs as a language construct would disappear. Or would the 
> current syntax remain via CTFE?

We would keep the existing syntax, but lower it to something else


More information about the Digitalmars-d mailing list