On Thu, Mar 15, 2012 at 10:22:06AM -0700, H. S. Teoh wrote: [...] > This is one major area that I forgot to mention, and that is, making AA > literals work at compile-time. Currently things like this don't work: > > enum myAA = ["abc":123, "def":456]; > > I'd like to make that work. That would require compile-time construction > of the AA and storing it in some form that the compiler can put into the > object file. I'm thinking of something along the lines of using mixins > to generate explicit instances of Slot structs, so the above would > translate to something like: [...]
Hmm. I just did a little test to see how feasible this is, and I create the AA Slots and array of pointers to slots fine, but hashOf() doesn't work in CTFE: /usr/src/d/druntime/src/rt/util/hash.d(38): Error: reinterpreting cast from const(ubyte)* to ushort* is not supported in CTFE /usr/src/d/druntime/src/rt/util/hash.d(72): called from here: get16bits(data) Should I submit a pull request for a __ctfe variant of hashOf so that it can be used for this purpose? Any gotchas I should be aware of? T -- "I'm running Windows '98." "Yes." "My computer isn't working now." "Yes, you already said that." -- User-Friendly
