Associative arrays

Imperatorn johan_forsberg_86 at hotmail.com
Tue May 18 14:42:26 UTC 2021


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:
>> This sounds like a reasonable position.  Imagine for a second 
>> that AAs were implemented as a library.  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);
> ```

How hard would it be to "overload/override" the AA syntax to 
allow different implementations? 🤔

Like a default would require nothing (as it is today) but if you 
somehow told the rt that "hey, I want to use this for AAs plz". 
Then if you want better performance you could over time just plug 
a new implementation in.

Why? So that existing code wouldn't have to be changed, but with 
some added configuration could get the benefits.


More information about the Digitalmars-d mailing list