"with" still sucks + removing features + adding features
Denis Koroskin
2korden at gmail.com
Tue May 19 05:44:55 PDT 2009
On Tue, 19 May 2009 16:19:32 +0400, Alexander Pánek <alexander.panek at brainsware.org> wrote:
> Andrei Alexandrescu wrote:
>> bearophile wrote:
>>> Andrei Alexandrescu:
>>>
>>> Thank you for bringing a "real" example that gives something to work
>>> on.
>>>
>>>> Awful!<
>>>
>>> Well, one of your cases was wrong. Using the +1 at the end one of
>>> those cases become:
>>> case 'A' .. 'Z'+1, 'a' .. 'z'+1:
>>> Instead of what you have written:
>>> case 'A' .. 'Z'+1: case 'a' .. 'z'+1:
>>>
>>> I agree that that syntax with +1 isn't very nice looking. But the
>>> advantage of +1 is that it introduces (almost) no new syntax, it's not
>>> easy to miss, its meaning is easy to understand. AND you don't have to
>>> remember that in a case the .. is inclusive while in foreach is
>>> exclusive on the right, keeping the standard way in D to denote ranges.
>> You don't understand. My point is not that people will dislike 'Z'+1.
>> They will FORGET TO WRITE THE BLESSED +1. They'll write:
>> case 'A' .. 'Z':
>
> You know, Ruby solves this by introducing a “seperate” range syntax for
> exclusive ranges: “...”. An inclusive range is written the same as an
> exclusive range in D: “..”.
>
> a[1 .. 2].length #=> 1 ([a[1]])
> a[1 ... 2].length #=> 2 ([a[1], a[2]])
>
> I see no reason not to include such a seperate syntax in D. “..” being
> exclusive and “...” being inclusive, not the other way round as in Ruby
> — see “Programmer’s Paradox” @
> http://www.programmersparadox.com/2009/01/11/ruby-range-mnemonic/ .
>
> Kind regards, Alex
I think this is reasonable.
++vote;
More information about the Digitalmars-d
mailing list