How to initialize a associative array?

Stefan Koch via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Dec 25 01:02:28 PST 2016


On Sunday, 25 December 2016 at 05:45:14 UTC, Era Scarecrow wrote:
> On Saturday, 24 December 2016 at 11:21:11 UTC, Stefan Koch 
> wrote:
>> On Saturday, 24 December 2016 at 00:55:01 UTC, Yuxuan Shui 
>> wrote:
>>> What's the correct way?
>>
>> You cannot initialize an AA at compile-time.
>> Because AA's are provided by druntime and the ABI is not 
>> stable.
>
>  For fun I'm throwing together a quick AA struct that you can 
> make at compile time. It's experimental and may be slow for 
> compiling as it needs to find a size of numbers where the 
> hashes don't overlap. Of course you can't add to it, you can't 
> delete elements (key limitations) but you could in theory 
> change the value; So this would be better for immutable objects 
> or having a fixed number of pre-known keys.
>
>  If anyone is interested I can share my sources fairly soon 
> once I'm satisfied the required features are done. So far 
> opIndex and generation works fine, but range/foreach over it is 
> incomplete.

There are library solutions for AA like containers that can be 
used at compiletime.
Maybe you could help polishing them ?
So we can eventually get them into druntime ?


More information about the Digitalmars-d-learn mailing list