in not working with enum'd AA

Jonathan M Davis jmdavisProg at
Mon Feb 27 09:45:04 PST 2012

On Monday, February 27, 2012 18:19:59 Nathan M. Swan wrote:
> On Monday, 27 February 2012 at 09:13:24 UTC, Jonathan M Davis
> wrote:
> > It would be far better to use immutable.
> > 
> > - Jonathan M Davis
> That doesn't work either, as it says:
> Error: non-constant expression
> ["import"d:cast(TokenType)2,"public"d:cast(TokenType)3,"protected"d:cast(Tok
> enType)4,"private"d:cast(TokenType)5,"static"d:cast(TokenType)6]

You have to initialize the AA in a static constructor (and use a _shared_ 
static constructor, since the AA is immutable and therefore shared across 
threads). You can't initialize it directly, because you can't have memory 
which is used at runtime continue to compile time. The only type that can do 
that on any level is a dynamic array. That can't be done with anything more 
complicated yet (like an AA or a class).

- Jonathan M Davis

More information about the Digitalmars-d mailing list