Compile-time AAs

Justin Johansson procode at adam-dott-com.au
Tue Sep 15 05:22:08 PDT 2009


Hear, hear, I second the motion .. especially if such feature can be used to implement reverse enums.

It's tedious writing reverse mapping tables (in C++) for converting the runtime value of an enum back to its symbolic (lexical) name for debug purposes.  Sounds like bearophile's CT AA might help to achieve this facility with ease in D.  Then again, the features of D that I'm still learning about continue to amaze me so perhaps one can do this (reverse enum) thing in D already .. just that it (the mystery feature) hasn't found me yet.

Cheers
Justin Johansson

<_/>


bearophile Wrote:

> Don has recently said that adding dynamic arrays at compile-time looks easy. I'd also like to have compile-time associative arrays. So you can fill them inside a CT function (the compiler may try to do the same for AAs created inside a static this(){}), and save some run time.
> Even if such compile-time AAs have to be immutable at run-time they can be useful anyway.
> A smarter implementation of such CT AAs may even use a perfet hashing, to make them quite fast.
> 
> Bye,
> bearophile




More information about the Digitalmars-d mailing list