Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!necntc!ima!haddock!karl From: karl@haddock.ISC.COM (Karl Heuer) Newsgroups: comp.lang.c Subject: Re: goto's and switch statements -- mild proposal Message-ID: <929@haddock.ISC.COM> Date: Wed, 12-Aug-87 17:02:34 EDT Article-I.D.: haddock.929 Posted: Wed Aug 12 17:02:34 1987 Date-Received: Sat, 15-Aug-87 01:48:37 EDT References: <855@tjalk.cs.vu.nl> <2683@hoptoad.uucp> <916@haddock.ISC.COM> <2182@zeus.TEK.COM> Reply-To: karl@haddock.ima.isc.com (Karl Heuer) Organization: Interactive Systems, Boston Lines: 21 In article <2182@zeus.TEK.COM> dant@tekla.UUCP (Dan Tilque) writes: >[If switch statements had automatic break instead of fall-through, the >current idiom "case CR: case LF: ..." wouldn't work.] One possibility is >separating them with commas: "case CR, LF, TAB, ' ':" which changes the >meaning of the comma operator. Probably not a good idea. The comma operator is neither necessary nor useful in a constant expression, and is explicitly disallowed by ANSI. >However, I agree that it's bad programming to have this kind of thing: >"case 'a': a = b + count; case 'b': count += 2;". Lint should >definitely give warning since it's almost always the case that what's desired >is a break before case 'b':. Also, one of my more frequent mistakes is >leaving breaks out of switches. I agree, but (failing something stronger, such as my proposal) it should be possible to turn off this warning, since some people intentionally write the above. A lintpragma /* FALLTHROUGH */ is the simplest solution. I think some implementations already have this. Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint