O(1) dictionaries

mandel oh at no.es
Thu Nov 15 07:22:13 PST 2007


Jari-Matti Mäkelä Wrote:

> mandel wrote:
> > The dict may also change order when words are added and quite possibly
> > regrouped. The entire alignment will be hard to maintain.
> 
> That's no good excuse to not use templates :P :
> 
[temlate kungfu]
> 
> mixin(RealEnum!("Word", "dict", "Hello", "Bye"));
> 
> CTFE would produce smaller binaries though.

Your template looks like it does it's jobs quite nicely - thx.

The reason I try to avoid templates is that they often look like
an entry for an obfuscation competition. ;>

Templates in D (in even much more in C++) are hard to understand,
they don't look like just compile time D code but like a new language.
(well, I guess the D compilers may need an integrated scripting engine to execute D code at compile time).

And as many developers, I try to avoid code templates if there is no real benefit or if they stay simple enough for other devs to understand at first sight.

I only use hackish code in speed critical sections (not like NASA, but critical in the sense of overall program speed).
well, dictionaries in my applications may fit in this role. :}





More information about the Digitalmars-d mailing list