On 2009-11-15 16:03:39 -0500, Andrei Alexandrescu
<[email protected]> said:
Walter Bright wrote:
Don wrote:
And looking at how rarely it's actually used by someone who thinks he
uses it a lot, convinces me that intentional use of fall-through is
much less common than bugs introduced by leaving out a break statement.
Except that I cannot recall ever having a bug from leaving out a break <g>.
I can. I'm not sure where that leaves us. Others - please add your experience.
I did not get my habit of adding a "// fallthrough" comment because
someone told me I should. It was after experiencing too many "forgotten
break" bugs that I began to do this so that now if I read some of my
code that doesn't explicitly mention it wants falltrhough, it looks
immeditately suspicious. Thus, it helps detecting bugs earlier.
Apparently, Walter's whitespace convention accomplish the same goal. I
wonder from where it comes...
Most of those missing break bugs I catch early when debugging or
reviewing, but that is still needlessly time-consuming considering it'd
be pretty simple for the compiler to make sure everything is all right.
--
Michel Fortin
[email protected]
http://michelf.com/