RFC on range design for D2

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Tue Sep 9 08:30:58 PDT 2008


Leandro Lucarella wrote:
> Andrei Alexandrescu, el  9 de septiembre a las 07:47 me escribiste:
>> Lionello Lunesu wrote:
>>> "Andrei Alexandrescu" <SeeWebsiteForEmail at erdani.org> wrote in message 
>>> news:ga46ok$2s77$1 at digitalmars.com...
>>>> I put together a short document for the range design. I definitely missed 
>>>> about a million things and have been imprecise about another million, so 
>>>> feedback would be highly appreciated. See:
>>>>
>>>> http://ssli.ee.washington.edu/~aalexand/d/tmp/std_range.html
>>> This is just awesome. Thank you for tackling this issue.
>>> I agree with others that some names are not so obvious. Left/right? How do 
>>> Arabic speakers feel about this : ) Begin/end seems more intuitive.
>> I don't know of that particular cultural sensitivity. Begin and end are
>> bad choices because they'd confuse the heck out of STL refugees. c.left
>> and c.right are actually STL's c.front() and c.back() or *c.begin() and
>> c.end()[-1], if you allow the notational abuse. But I sure hope some
>> good names will come along.
> 
> I think STL refugees can deal with it. I think there is no point on keep
> compromising D's readability because of C/C++ (you just mentioned enum,
> another really bad choice to keep C/C++ refugees happy).

I agree. I just don't think that choosing one name over a synonym name 
compromises much.

> I find left and right a little obscure too, it all depends on your mental
> image of a range. Using front/back or begin/end is much more clearer.

I'd like to go with:

r.first
r.last
r.next
r.pop

Not convinced about r.toBegin(s), r.toEnd(s), and r.fromEnd(s) yet, in 
wake of a realization. I've noticed that the r.fromBegin(s) operation is 
not needed if we make the appropriate relaxations. r.fromBegin(s) is 
really s.toEnd(r).

I've updated 
http://ssli.ee.washington.edu/~aalexand/d/tmp/std_range.html with a 
drawing (right at the beginning) that illustrates what primitives we 
need. Maybe this will help us choose even better names.


Andrei


More information about the Digitalmars-d-announce mailing list