DMD 1.014 release

BCS BCS at pathlink.com
Fri Apr 27 09:02:03 PDT 2007


Don Clugston wrote:
> 
> In practice, you _can_ have initialized static AAs, provided they are 
> read-only (which is probably the main time you want to supply 
> initializers). The declaration syntax for a read-only AA slightly lacks 
> syntactic sugar, but the syntax for usage is perfect:
> 
> char[][uint] symTable() { return [2u:"he",4:"ho",6:"hi"]; }
> 
> void main()
> {
>     for (int k=1; k<=6; ++k) {
>         if ((k&1)==0) printf("%.*s\n", symTable[k]);
>     }
> }
> 

function call overhead on every use? Ouch!!

I'd rather go with

char[][uint] symTable; static this(){symTable=[2u:"he",4:"ho",6:"hi"];}



More information about the Digitalmars-d-announce mailing list