Article View: comp.std.c++
Article #446Re: Proposed Enhancement to select/case (yes, I know...)
From: Dave Gillespie
Date: Wed, 05 Sep 1990 00:56
Date: Wed, 05 Sep 1990 00:56
27 lines
1843 bytes
1843 bytes
>>>>> On 1 Sep 90 22:43:36 GMT, henry@zoo.toronto.edu (Henry Spencer) said:
> In article <1990Aug31.134248@ee.ubc.ca> mikeb@salmon.ee.ubc.ca writes:
>> case 'A'..'Z': printf ("upper case\n"); break;
> Heh heh. What does this do on an EBCDIC machine? Not what you think!
Here's a solution: In <ctype.h> define macros which expand to the
necessary case ranges and/or lists for various subsets of the target
character set: Lowercase alpha, uppercase alpha, and digits.
A somewhat ugly but workable underlying case syntax would be, e.g.:
case 'a'..z'; 'A'..'Z'; '_': begin_c_identifier(); break;
One flaw with this is that isalpha() can be defined to be run-time
configurable for different national alphabets, but macros cannot.
Perhaps the "right" extension is to allow arbitrary predicates in
a case label ("case isalpha:"), but I can't think of a really nice
syntax for it, especially if you want to allow macros to be used as
the predicate.
-- Dave
--
Dave Gillespie
256-80 Caltech Pasadena CA USA 91125
daveg@csvax.cs.caltech.edu, ...!cit-vax!daveg
Technical Details
Message-ID:
<DAVEG.90Sep4175616@near.cs.caltech.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!sdd.hp.com!elroy.jpl.nasa.gov!jarthur!nntp-server.caltech.edu!laguna.ccsf.caltech.edu!davegReferences:
<BURLEY.90Aug30030645@world.std.com> <1990Aug30.164610.3519@zoo.toronto.edu> <1990Aug31.134248@ee.ubc.ca> <1990Sep1.224336.22846@zoo.toronto.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!sdd.hp.com!elroy.jpl.nasa.gov!jarthur!nntp-server.caltech.edu!laguna.ccsf.caltech.edu!daveg From: daveg@near.cs.caltech.edu (Dave Gillespie) Newsgroups: comp.std.c++,comp.std.c Subject: Re: Proposed Enhancement to select/case (yes, I know...) Message-ID: <DAVEG.90Sep4175616@near.cs.caltech.edu> Date: 5 Sep 90 00:56:16 GMT References: <BURLEY.90Aug30030645@world.std.com> <1990Aug30.164610.3519@zoo.toronto.edu> <1990Aug31.134248@ee.ubc.ca> <1990Sep1.224336.22846@zoo.toronto.edu> Sender: news@laguna.ccsf.caltech.edu Organization: California Institute of Technology Lines: 27 In-Reply-To: henry@zoo.toronto.edu's message of 1 Sep 90 22:43:36 GMT