Official DMD compiler written in D

H. S. Teoh hsteoh at quickfur.ath.cx
Thu Jan 10 11:50:35 PST 2013


On Thu, Jan 10, 2013 at 08:38:08PM +0100, Era Scarecrow wrote:
>  Eep, seems I hit send...
> 
> On Thursday, 10 January 2013 at 05:47:01 UTC, H. S. Teoh wrote:
> >The basic idea behind static AA literals is to use CTFE to compute
> >the hashes of the keys, and therefore which slot(s) they will fall
> >in, at compile time. Armed with this information, we can create an
> >array of slots at compile-time that contains the AA entries by
> >declaring each slot as a static variable and using the slot
> >assignment information to initialize the hash table (array of
> >pointers to slots) to point to these slots.
> 
>  Hmmm somehow that doesn't seem like a good idea; I mean it will
> work....
> 
>  Alternative is to sorta have a pair of static arrays, then either
> use a balanced tree, or a modulus to best hold (and separate) the
> values.
[...]

The issue here is that I wanted to avoid the complication of having a
separate set of functions to lookup the AA literal vs. a runtime AA (and
trust me, things get *very* hairy if you go that route -- it requires
non-trivial compiler hacks to make things work with two distinct AA
types), so whatever is generated at compile-time must be the same
structure as runtime AA's so that the same AA methods will work on both.

If this is unimportant, then I would've done it another way.


T

-- 
MACINTOSH: Most Applications Crash, If Not, The Operating System Hangs


More information about the Digitalmars-d mailing list