No fall-through for switch (WAS: Re: [Submission] D Slices)
bearophile
bearophileHUGS at lycos.com
Mon Jun 13 10:07:10 PDT 2011
Andrej Mitrovic:
> Hey I've just realized something (well, it was in the docs, doh!), we
> can use already use "switch case;" to fallthrough to the next label
> without explicitly using goto:
>
> void main()
> {
> int x = 2;
> switch (x)
> {
> case 2:
> goto case; // goto case 3;
> break;
>
> case 3:
This is good to have, but I don't find this syntax easy to understand, readable, natural. A "@fallthrough" is much more explicit, but it's a very specialized thing.
Bye,
bearophile
More information about the Digitalmars-d
mailing list