switch break/fall (last minute request ... )
Bill Baxter
dnewsgroup at billbaxter.com
Mon Dec 25 18:46:58 PST 2006
%u wrote:
> == Quote from Hasan Aljudy (hasan.aljudy at gmail.com)'s article
>> case C:
>> //something
>> case D: <-- error, no break or fall statement before case
> D
>
> So:
>> case C:
> if( b1 )
> { fall; break;}
> else
> if( b2)
> goto case C;
> else
> { break; fall;}
>> case D:
>
> would be legal?
I'm pretty sure this one has been discussed to death in the past, so I
doubt any last minute plea is going to change anything, for 1.0 at
least. :-)
Walter's position previously has been that he didn't want to confuse the
poor C/C++/Java converts regardless of how error-prone default fall
through is.
If you look at the kind of code Walter writes (see parse.c in the DMD
source in particular), you'll see that he is quite fond of stacking up
multiple case labels, so I doubt he'd ever agree to make
case TOKstruct:
case TOKunion:
case TOKclass:
case TOKinterface:
s = parseAggregate();
break;
an error.
However, what if you modify the rule slightly so that if a case follows
another case immediately, then a 'fall' is not required? Then Walter
may yet find it palatable.
I'm all for it, though. I've been debugging my own missing 'break'
statements for 20 years now, and I still never seem to learn.
--bb
More information about the Digitalmars-d
mailing list