John Colvin via Digitalmars-d
2014-10-14 21:29:58 UTC
A few reasons why it doesn't:
You have to duplicate the case keyword when declaring case
Case ranges are inclusive at both ends of the range, unlike in
foreach. Again, why?
exponential notation (e.g. `2e9`) returns a double, not a long.
The exponential notation isn't really a problem, declaring some
enums `enum i2e9 = cast(long)2e9;` deals with it fine. The case
ranges are a wart though.
Allow the second `case` keyword to be removed, which would then
have the same semantics as the range in foreach.
case 0 .. 4: // matches 0,1,2,3
case 0: .. case 4: // matches 0,1,2,3,4
No breakage, greater consistency, neater code, good stuff. At
least as good as pascal.
Even better, the .. operator would become general (overloadable,
too) and the case range would just be a special case of it.