No more fall through in case statement?

Rioshin an'Harthen rharth75 at hotmail.com
Wed Jan 9 01:57:27 PST 2008


"Jason House" <jason.james.house at gmail.com> kirjoitti viestissä 
news:fm05pk$2v7k$1 at digitalmars.com...
> My personal take on all this switch stuff is:
>  * Silently falling-through is dangerous
>     (common switch error when coding, easy to miss in code review)
>  * Silently not falling-through is dangerous (to C coders, etc)
>  * A single case with commas is great, but won't be used by all
>  * {} syntax may be a reasonable compromise
>  * Explicitly requiring "break", "fall", or "assert(0)" at the end of a 
> case
>     may be the best solution.

I'd like to see either a "break", "continue", or "return" (or any other
means of exiting a case, like "goto") at the end of a case statement
required, but I'd settle for the compiler to at least produce a warning
in the case one of these are missing. "continue" at the end of the case
statement would mean fall-through behavior, all others are as is. 




More information about the Digitalmars-d mailing list