Assigning global and static associative arrays

Philippe Sigaud philippe.sigaud at gmail.com
Sun Sep 2 12:24:43 PDT 2012


On Sun, Sep 2, 2012 at 8:50 PM, Ali Çehreli <acehreli at yahoo.com> wrote:
> On 09/02/2012 06:45 AM, monarch_dodra wrote:
>
>> Is there *any* scenario where one would choose the enum over the
>> static immutable...?

Due to Jonathan advice, I converted a part of my code (enum => static
this). At runtime, I got a 40% decrease in runtime, a *very* good
news. But then CTFE does not work anymore: some functions tell me the
static AA I use is not initialized (or whatever).
I tried to use if(__ctfe) but then I lose most of the speedup.

All in all, for my Pegged parser generator project, I ended up
generating code specifically for compile-time (for CT parsing) and
some other function for runtime. So yes, enums are useful for CT
computation sometimes.


More information about the Digitalmars-d-learn mailing list