Associative Array Initalizers - Possible Syntax?

Nicolai Waniek no.spam at thank.you
Mon Feb 12 12:19:23 PST 2007


Hi!

Xinok wrote:
> 
> 
> It might be easier to read if braces were used { } for the index list though:
> int[int][int] arr = [{0, 10, 20} = [{5} = 0, {15} = 10, {25} = 20]];
> 

I don't like each version you provided. The most readable and D-ish (in
comparison to static initialization) would be something like this example:

char[][][char[]] languageTokens =
    [
      "comments" : ["\\*", "*\\", "//", "\\+", "+\\],
      "type"     : ["bool", "int", "double", "float"]
    ];

and so on.

> And yes, I've already seen the associative array initalizer using mixins...

I don't know mixins because I don't like mixins (as well as I don't
really like templates).


Nicolai



More information about the Digitalmars-d mailing list