About switch case statements...

MIURA Masahiro echochamber at gmail.com
Mon Nov 16 01:48:09 PST 2009


On 11/16/2009 06:16 PM, Denis Koroskin wrote:
>> If I remember correctly, one of D's design policies is
>> that a D code that looks like C code should behave like C.
>> Are we giving up that policy?
> Correction: either behave like C, or raise a compile-time error.

Yes.  I should have written "a valid D code".

> Missing break statement will not cause a different behavior. It will
> fail to compile.

Could you clarify?  In you proposal, does a break statement
breaks out of the switch?  Then,

for (;;) {
     switch (foo) {
     case "FOO":
         break;
     }
}

In C, 'break' exits the for-loop.  In your proposal, it doesn't.



More information about the Digitalmars-d mailing list