Xref: utzoo comp.std.c++:292 comp.std.c:3535 Path: 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: Date: 5 Sep 90 00:56:16 GMT References: <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 >>>>> 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 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