No more fall through in case statement?
0ffh
frank at youknow.what.todo.interNETz
Thu Jan 3 06:22:19 PST 2008
Janice Caron wrote:
> On 1/3/08, 0ffh <frank at youknow.what.todo.internetz> wrote:
>> To me, a warning on nonempty case fallthrough seems more than enough...
>
> I'm sure you know this already, but: "Warnings are not a defined part
> of the D Programming Language."
> (http://digitalmars.com/d/warnings.html)
Right-ho! I do, but I was thinking of C#, what the article was about. =)
Actually, I think that "no warnings" is a mistake, as is "no inline".
> [...]
>
> For example:
>
> case 1:
> /*...*/
> /* falls through */
> case 2:
> /*...*/
> break;
> case 3
> {
> /*...*/
> }
> /* does not fall through */
>
> [...]
> Everyone's happy. (Maybe?)
I like it as it is. If it absolutely has to be changed, why not
replace the explicit break with an implicit break and make fall-
through explicit? Liek so:
case 1:
/*...*/
fallthrough; // falls through
case 2:
/*...*/
// no fallthrough -> implicit break
case ...
I could live with that as a compromise...
regards, frank
More information about the Digitalmars-d
mailing list