Is there ANY chance we can fix the bitwise operator precedence rules?

Jonathan M Davis jmdavisProg at gmail.com
Mon Jun 21 16:01:57 PDT 2010


Andrei Alexandrescu wrote:
> 
> After Sean's example, goto case XXX is my fave for fallthrough. I don't
> like unlabeled "goto case" to mean fall through, it's one of those "need
> to look in the manual" features. goto case XXX is generalized fall
> through.
> 
> Andrei

Well, it definitely works, but then you run into the issue of whether you 
used the right XXX. That's the kind of place that rearranging code is likely 
to run into bugs whereas "goto case" by itself or "continue switch" would 
just fall through. It also makes it less obvious when you have errors with 
"goto case XXX" being intended to jump somewhere other than the next case. 
If you're using a statement that is explicitly for falling through, then 
it's clearly differentiated from a statement where you're jumping to a case 
other than the next one. I can't say that I'm terribly found of "goto case" 
by itself, but at least it would be less likely to cause bugs when 
rearranging code and more clearly indicates the intention to fall through. 
It still isn't as good a statement which can only be used for fallthrough 
(and therefore couldn't be a "goto case" where you were supposed to put a 
target but didn't), but I see no advantage in using "goto case XXX" for 
fallthrough instead of "goto case".

"goto case" does seem a bit silly, but I think that it's clearer and less 
error prone for anyone who understands "goto case." The only issue is the 
fact that it would be odd for someone who didn't know that you could do 
that, but there's plenty of that to go around already, and it's not like it 
would be hard to remember when you see it if you've already looked it up.

- Jonathan M Davis


More information about the Digitalmars-d mailing list