🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #485

Re: Proposed Enhancement to select/case (yes, I know...)

#485
From: Richard A. O'Keefe
Date: Thu, 06 Sep 1990 10:06
39 lines
2211 bytes
In article <BURLEY.90Sep4054715@world.std.com>, 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' <choice> {| <choice>}...		(LRM 5.4)
and 	<choice> ::= 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.
Technical Details
Message-ID: <3699@goanna.cs.rmit.oz.au>
Path: arc1-ca.pugleaf.net!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
References: <BURLEY.90Aug30030645@world.std.com> <1420@lupine.NCD.COM> <BURLEY.90Sep4054715@world.std.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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: <BURLEY.90Aug30030645@world.std.com> <1420@lupine.NCD.COM> <BURLEY.90Sep4054715@world.std.com>
Distribution: comp
Organization: Comp Sci, RMIT, Melbourne, Australia
Lines: 39