Xref: utzoo comp.std.c++:279 comp.std.c:3531 Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!usc!wuarchive!uunet!lupine!rfg From: rfg@NCD.COM (Ron Guilmette) Newsgroups: comp.std.c++,comp.std.c Subject: Re: Proposed Enhancement to select/case (yes, I know...) Message-ID: <1420@lupine.NCD.COM> Date: 1 Sep 90 17:12:07 GMT References: Followup-To: comp.std.c++ Distribution: comp Organization: Network Computing Devices, Inc., Mt. View, CA Lines: 78 In article burley@world.std.com (James C Burley) writes: < <...But how about this: allow ranges (and, perhaps, lists) on case statements. There are two separate questions here. One concerns case ranges, and the other concerns lists. I perfer to talk about each separately. Regarding case ranges, my personal feeling is that this is a good and useful feature and that it ought to make its way into the final standard for C++. It is my understanding that this feature was proposed during the ANSI C deliberations, but that it was rejected by X3J11 (for reasons that I'm not clear on). Perhaps someone who served on X3J11 could give us a quick summary about what happened to case ranges in X3J11. Anyway, ANSI C standard or no, some C compiler vendors do offer this feature. The only one I'm sure offers it is MetaWare. In the C++ would, g++ offers case ranges. This should prevent X3J16 members from rejecting the idea outright because of a lack of prior art. By the way, I believe that both MetaWare C and g++ implement case ranges via a syntax like: case LOW..HIGH: Regarding "case lists", it seems clear that a simple syntax, i.e.: case FOO,BAR: won't work because the separator comma could be parsed as the normal comma operator, which would mess up everything. James proposes: case [FOO,BAR]: which is more verbose than the simple syntax but which still saves a bit of typing relative to: case FOO: case BAR: The only problem is that the values used to designate cases should (if reason prevails) still be allowed to be formed from "static constant expressions" and thus, the problem of the comma being parsed as a comma operator still plagues this syntax also. Anyway, it looks like developing a special syntax for "case lists" may be more trouble than it is worth.