switch ( Expression ) ScopeStatement

BCS none at anon.com
Mon Jul 6 19:50:04 PDT 2009


Hello bearophile,

> Derek Parnell:
> 
>> is valid syntax! Why is that?
>> 
> To allow train-wrecks like this one:
> 
> version(Tango) import tango.stdc.stdio;
> void main(char[][] args) {
> if (args.length > 1)
> switch (args[1]) {
> int x = 1; // This initialization to 1 doesn't happen,
> // it's the same as int x = void;
> case "1": printf("1! x=%d\n", x); break;
> case "2": printf("2! x=%d\n", x); break;
> }
> }
> Bye,
> bearophile

you want a train wreck?


void main()
{
    switch(5) default: { case 6: {} }
}




More information about the Digitalmars-d-learn mailing list