Foreach Range Statement
Sean Kelly
sean at f4.ca
Mon Jul 23 08:45:07 PDT 2007
Reiner Pope wrote:
> Bill Baxter wrote:
>> Don Clugston wrote:
>>> I think the convention "first_element .. last_element+1" cannot be
>>> extended to negative and floating-point numbers without creating an
>>> inconsistency. Which is quite unfortunate.
>
> I'm not sure of the problem with negative integers is. Even for negative
> integers x, the identity still holds, that the following two expressions
> are equivalent:
>
> a <= x
> a < x+1
>
> But the floating point issue is a bummer. And it's also a bit silly for
> chars. To test whether c is a digit, you would have to write:
>
> c in ['0'..'9'+1]
>
> which looks a little silly.
Perhaps there should be an operator for inclusive vs. exclusive ranges.
Something like:
c in ['0' -> '9']
Not ideal, I know.
Sean
More information about the Digitalmars-d
mailing list