Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!sun-barr!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!rpi!batcomputer!munnari.oz.au!goanna!ok From: ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) Newsgroups: comp.std.c++ Subject: Re: Proposed Enhancement to select/case (yes, I know...) Message-ID: <3699@goanna.cs.rmit.oz.au> Date: 6 Sep 90 10:06:27 GMT References: <1420@lupine.NCD.COM> Distribution: comp Organization: Comp Sci, RMIT, Melbourne, Australia Lines: 39 In article , burley@world.std.com (James C Burley) writes: (quoting someone else) > I think not. I'm pretty sure that case ranges appeared in Pascal long > before anybody in FORTRAN land ever though of the idea. > Also, I don't know whether Pascal has the "..LOWER", "UPPER.." range forms that > match x<=LOWER and UPPER<=x, respectively. Case ranges are not part of ISO standard Pascal *AT* *ALL*. The new "Pascal Extended" may well have them, but the old standard, no. Case ranges have been *much* discussed in SigPlan Notices and elsewhere for the last 20 years. (They _would_ have fitted very nicely into Pascal if only case labels had been constant set expressions.) Case ranges *are* however part of Ada, where a "case label" is 'when' {| }... (LRM 5.4) and ::= simple_expression (LRM 3.7.3) | simple_expression .. simple_expression | subtype_name -- defined as a range | range_valued_attribute | 'others' So case Ch is when 'a' .. 'z' | 'A' .. 'Z' => Letter; when '0' .. '9' => Digit; when others => NonAlNum; end case; No, Ada does not have ..upper or lower.., however it is always possible to use T'FIRST..upper for ..upper lower..T'LAST for lower.. where T is the type of the case expression. In C or C++ it would suffice to use case INT_MIN .. upper: for case .. upper: case lower .. INT_MAX: for case lower ..: I don't say it's as pretty, but INT_MIN and INT_MAX are already there. -- You can lie with statistics ... but not to a statistician.