On 2009-11-15 12:54:02 -0500, Andrei Alexandrescu <[email protected]> said:

Walter's answer to that has put me to silence for good. "But I use fall-through all the time!" I then knew the feature will never make it.

Hum two suggestions. Sometime I want fall-through when I write a switch, but I always make it clear that it isn't a bug by writing the intent in a short comment:

        switch (c) {
                case 1:
                        blah();
                        break;
                case 2:
                        blah();
                        // fallthrough
                case 3:
                        blah();
                        break;
        }

That way I can always tell when I read again the code wether this was intentional or not. It wouldn't hurt at all if that "fallthrough" comment became a keyword:

        switch (c) {
                case 1:
                        blah();
                        break;
                case 2:
                        blah();
                        fallthrough;
                case 3:
                        blah();
                        break;
        }

Now the intent is clear even for the compiler.

--
Michel Fortin
[email protected]
http://michelf.com/

Reply via email to