Proposed Enhancement to select/case (yes, I know...)
James C Burley
burley at world.std.com
Tue Sep 4 18:58:14 AEST 1990
In article <1990Sep1.224336.22846 at zoo.toronto.edu> henry at zoo.toronto.edu (Henry Spencer) writes:
In article <1990Aug31.134248 at ee.ubc.ca> mikeb at 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!
I think if you look at my original posting, you'll see a kind of backhand
mention of this issue (I said something about it not being any more portable
than a switch with a bunch of cases, in fact maybe less portable).
Anyway, in case you missed it, the issue has been "decided". GNU C already
implements such a construct; and it is a widely used compiler. When the
next standard begins "happening", it will be up to the committee (with all
our input) to determine whether ranges (and lists) are useful and simple enough
to add, compared to the costs of any possible lack of portability being
introduced.
Meanwhile, I personally would not use the range feature for the above case
except in some kind of quick&dirty throwaway program. I'm looking to it
more as an elegant way to deal with natural (i.e. portable) ranges that occur
in applications, and cases where the switch (not select, as I'm wont to say
as a Fortran-90 victim) statement and it's case statements are being written
by someone who does not (or should not/doesn't want to) know the values of
#define constants for the cases (presumably kept in an #include file) but
still wants to handle ranges. Nothing wrong with that, I wouldn't think.
James Craig Burley, Software Craftsperson burley at world.std.com
More information about the Comp.std.c
mailing list