Associative Arrays in the data segment

Daniel Murphy via Digitalmars-d digitalmars-d at puremagic.com
Fri Apr 10 20:45:07 PDT 2015


"Andrei Alexandrescu"  wrote in message 
news:mg94od$1v4g$1 at digitalmars.com...

> Can you make a salient argument that this is a step in the right 
> direction? In that case what's the vision for future steps? Thanks! -- 
> Andrei

This approach makes the common cases of AAs in the data segment work.  This 
enables a very useful idiom of defining a constant lookup table and using it 
at runtime to map values.

The hashing and AA implementations that need to be replicated in the 
compiler are trivial, and easily updated if anybody does change the druntime 
implementation.  At worst it's pretty much a copy-paste from the druntime 
sources.  And as I've said, I'm happy provide a matching dmd implementation 
of anybody's new druntime implementation.

A future library AA implementation would not be complicated by this patch, 
because the code in this patch is only reached when an AA literal survives 
until codegen.  A library AA would lower the AA literal to some other 
construct before codegen.

This is a step in the right direction because it will make the common cases 
of this feature work.  That's it.  It doesn't hurt or help other AA issues 
in a significant way. 



More information about the Digitalmars-d mailing list