Switch: Case Range Syntax
bearophile
bearophileHUGS at lycos.com
Wed Aug 17 13:29:19 PDT 2011
Jacob Carlborg:
> D should have a built-in range type. One that supports syntax for both
> including and excluding the last element:
>
> auto a = 3 .. 5
> auto b = 3 ... 5
>
> Then we wouldn't need a special range syntax for switch statements.
Regarding just switches, GCC has a non standard syntax extension that allows you to write case 'a' ... 'z':
http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_5.html#SEC90
But it also says:
> Note: Always write spaces around the ..., for otherwise it may be parsed wrong
> when you use it with integer values. For example, write this:
> case 1 ... 5:
> rather than this:
> case 1...5:
Bye,
bearophile
More information about the Digitalmars-d
mailing list