Fake global associative array literals
    bearophile 
    bearophileHUGS at lycos.com
       
    Sat Oct 29 02:20:35 PDT 2011
    
    
  
Nick Sabalausky:
> You generally need to be very careful about adding module/static ctors, 
> because they can easily lead to the dreaded circular ctor runtime error. So 
> as nice as it would be to use AA initializers at the module-level, this 
> carries a hidden danger which could be a royal PITA to debug (especially for 
> D newbies), so I don't think it's a good thing to do.
Second try. What about the lowering of:
int[int] aa = [1:2, 3:4];
void main() {}
To (now the static this generated for this initialization is enforced to be pure):
int[int] aa;
pure static this() {
    aa = [1:2, 3:4];
}
void main() {}
Is this enough to avoid the problems you talk about?
Bye,
bearophile
    
    
More information about the Digitalmars-d-learn
mailing list