On 2011-08-17 21:58, Timon Gehr wrote:
On 08/17/2011 09:35 PM, Jacob Carlborg wrote:
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. You
could store ranges in variables and pass them to functions. opSlice
probably wouldn't be needed, instead opIndex could be used and you would
declare the method to take a range instead of two integers.


The .. 'operator' is the operator with the lowest precedence in D (it
binds even less strongly than ?:), so there is no way auto a = 3 .. 5
can ever work without a breaking language change.

I don't see either how this could be changed without a breaking language change.

But again, 'case range:' matches 'range', not each individual element of
'range' so you'd actually still need a special range syntax for case
statements.


Wouldn't that depend on how it's implemented.

--
/Jacob Carlborg

Reply via email to