RFC on range design for D2

Lionello Lunesu lionello at lunesu.remove.com
Mon Sep 8 18:29:14 PDT 2008


"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.

Can you explain this please. From Input range:

e=r.getNext Reads an element and moves to the next one. Returns the read 
element, which is of type ElementType!(R). The call is defined only right 
after r.isEmpty returned false.

That last part: The call is defined only right after r.isEmpty returned 
false.

First of all, is* functions always sound "const" to me, but the way you 
describe isEmpty it sounds like it actually changes something, advancing a 
pointer or something like that. What happens if isEmpty is called twice? 
Will it skip 1 element?

The input range behaves like C#'s IEnumerator, but at least the C# names are 
more obvious: while (i.MoveNext()) e = i.Current; But isEmpty is common to 
all ranges, so I understand why it's the way it is. I just hope it could 
stay "const", not modifying the internal state. Perhaps add "next" to input 
ranges as well?

L. 



More information about the Digitalmars-d-announce mailing list