Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!spdcc!m2c!frog!john From: john@frog.UUCP (John Woods, Software) Newsgroups: comp.lang.c Subject: Re: Switch statements Message-ID: <1604@frog.UUCP> Date: Thu, 10-Sep-87 17:12:00 EDT Article-I.D.: frog.1604 Posted: Thu Sep 10 17:12:00 1987 Date-Received: Sat, 12-Sep-87 10:49:47 EDT References: <855@tjalk.cs.vu.nl> <2683@hoptoad.uucp> <916@haddock.ISC.COM> <2347@mmintl.UUCP> Organization: Superfrog Heaven [ CRDS, Framingham MA ] Lines: 33 In article <2347@mmintl.UUCP>, franka@mmintl.UUCP (Frank Adams) writes: #>In article <1022@haddock.ISC.COM> karl@haddock.ima.isc.com (Karl Heuer) writes: P>>In other words, "case CR, LF:" would have the new semantics, whereas R>>"case (CR, LF):" would be equivalent to "case LF:". This is no more A>>problematic than the current overloading of comma for function calls. G> M>Does anyone have any suggestions for a good syntax to indicate to the A>compiler that this check is not desired; that if the discriminant is not one >of the specified cases, the result of the switch is to be undefined? This seems to be the ideal case of what the ANSI people designed #pragma for. Before the switch statement you would have the line #pragma Pretty please, Mr. Compiler, don't check the range on this switch! and voila! code that's quick if the compiler recognizes the pragma, code that's correct even if it doesn't. Perhaps the ANSI committee should give some thought to standardizing certain "suggested" #pragmas. (Note: my general feeling about #pragma is similar to that of the writers of the GNU C compiler, who have the compiler run hack if it encounters a #pragma line... If one has to have a 69-way #elseif sequence to trick innumerable compilers into doing the same thing, what good is it?) (As it happens, the Greenhills C compiler has a command-line switch to turn off range checking of switch statements, but it is on a per-file basis, which seems a tad extreme.) -- John Woods, Charles River Data Systems, Framingham MA, (617) 626-1101 ...!decvax!frog!john, ...!mit-eddie!jfw, jfw@eddie.mit.edu Maybe it's the sound of a WET RAG hitting a smooth WEASEL!