Bartc said:
OK, let's try:
switch (cmdcode)
{case 1000..1999: filecmds(); break
case 2000..2499: editcmds(); break;
case 2500..2999: viewcmds(); break
default: misccmds();
};
Did you find this (or its equivalent) in an actual
program, or did you simply make it up? My point is not
that a ranged-case switch cannot be imagined, but that
its actual utility is in doubt. Can you find an example
of a real program -- or even a realistic programming
situation -- where case ranges would be helpful?
The 'A'..'Z' is perfectly OK for an ASCII machine, and there must be a
billion of those so it can be acceptable for such a 'restricted' target.
But for purists, how about a function Asc() that converts a C character code
into ASCII:
A programmer who assumes ASCII nowadays is begging
for a tongue-lashing from Anders Ångström, Béla Bartók,
Julius Cæsar, and everyone else through Jan Žižka. The
commonly-used character sets that express these and many
other words contain ASCII as a subset, and the upper-case
letter codes in those sets are not numerically contiguous.
The 'A' ... 'Z' range was useful once upon a time,
when we lived more insularly than we do today. But think:
We're talking about a feature that would be "new," not one
that would have been useful Back In The Day. When you're
writing a new program, is the proposed feature useful?