Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!ucla-cs!zen!ucbvax!decvax!linus!philabs!micomvax!musocs!mcgill-vision!mouse From: mouse@mcgill-vision.UUCP Newsgroups: comp.lang.c Subject: Re: goto's and switch statements -- mild proposal Message-ID: <867@mcgill-vision.UUCP> Date: Sun, 23-Aug-87 01:00:46 EDT Article-I.D.: mcgill-v.867 Posted: Sun Aug 23 01:00:46 1987 Date-Received: Sun, 30-Aug-87 20:26:16 EDT References: <855@tjalk.cs.vu.nl> <2683@hoptoad.uucp> <916@haddock.ISC.COM> <929@haddock.ISC.COM> Organization: McGill University, Montreal Lines: 40 In article <929@haddock.ISC.COM>, karl@haddock.ISC.COM (Karl Heuer) writes: > In article <2182@zeus.TEK.COM> dant@tekla.UUCP (Dan Tilque) writes: >> [switch statements with auto-break breaks "case foo: case bar: ...;"] >> One possibility is separating them with commas: "case CR, LF:" which >> changes the meaning of the comma operator. > The comma operator is neither necessary nor useful in a constant > expression, and is explicitly disallowed by ANSI. Necessary? True, since a constant expression by definition has no side-effects. Useful? I disagree. One of the prime uses of the comma operator is for macros to expand into, and it can be nice (ie, clearer, better style (whatever that means)) to be able to use a macro which generates a comma expression, but whose result is constant with the correct arguments, in a context like a switch case which requires a constant expression. (What a sentence.) I don't see an example immediately, but that's a poor excuse when I come up against a case where I want one. And it seems very against the UNIX philosophy, and therefore the C philiosophy, to forbid something merely because it seems useless at first glance. >> However, I agree that it's bad programming to have [fall-through in >> a switch, with statements between the case labels]. [...] it's >> almost always the case that what's desired is a break before [the >> second case]. Also, one of my more frequent mistakes is leaving >> breaks out of switches. Well, *I* don't have any trouble, because I have arranged my C-mode such that Emacs won't dedent the case for me unless I have either a break or a /* fall through */ there. > I agree, but [...] it should be possible to turn off this warning, I agree 155%. Any warning should have a means to turn it off. (For most current warnings, which tend to be type clashes, this means is provided: it's called a cast.) der Mouse (mouse@mcgill-vision.uucp)