Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxn!ihnp4!bentley!kwh From: kwh@bentley.UUCP (KW Heuer) Newsgroups: net.lang.c Subject: Re: A good use of a bad feature Message-ID: <800@bentley.UUCP> Date: Fri, 9-May-86 00:18:07 EDT Article-I.D.: bentley.800 Posted: Fri May 9 00:18:07 1986 Date-Received: Sat, 10-May-86 07:54:22 EDT References: <528@brl-smoke.ARPA> Organization: AT&T Bell Laboratories, Liberty Corner Lines: 37 Summary: Fall-thru is *not* better! In article <528@brl-smoke.ARPA> root@icst-cmr ((Root Boy) Jim Cottrell) writes: [concerning the fall-through case feature] >You will find much disagreement on that point, I'm afraid. Fall thru is >more flexible. You can always break, but often cases are related so that >a particular case requires a superset of another case. It is to DMR's >credit that he realized this feature. I sure wouldn't have thought of it. An alternate implementation would have been for cases to be distinct by default, but "continue" at the bottom of a case would cause a fall-thru. (In this model, "break" would be meaningless inside a switch and "continue" would be meaningful, instead of the opposite.) Given that most use of the switch statement *does* have distinct cases, and the exceptions are often explicitly labeled /* no break */, I think this would've been better. (I would *almost* accept a model with automatic break and no keyword for fall-thru, and suffer the occasional goto.) One special instance is where the superset is actually an equivalence, i.e. two or more labels on the same code: case ' ': case '\t': case '\n': white(); break; This would be ugly with the auto-break model, but the solution is to allow case ' ','\t','\n': white(); which I think looks neater anyway. (Btw, I find case '0': ... case '9': digit(); annoyingly verbose in the current model, and often use "if" rather than "switch" because of it.) Karl W. Z. Heuer (ihnp4!bentley!kwh), The Walking Lint