RFC on range design for D2

Lionello Lunesu lionello at lunesu.remove.com
Tue Sep 9 18:07:12 PDT 2008


"Andrei Alexandrescu" <SeeWebsiteForEmail at erdani.org> wrote in message 
news:ga5r8i$h0v$1 at digitalmars.com...
> So in essence the behavior is that you can use isEmpty to
> make sure that getNext won't blow in your face (speaking of Pulp
> Fiction...)

So isEmpty is optional for input ranges? This does not actually match your 
own documentation:

>getNext: The call is defined only right after r.isEmpty returned false.

If you make isEmpty optional, its non-constness is less of a problem. What I 
have a problem with (overstatement) is having to call isEmpty to actually 
prepare the next element. If try { while (1) e = ir.getNext; } works, I'm 
sold : )

> r.isEmpty does whatever the hell it takes to make sure whether there's
> data available or not. It is not const and it could throw an exception.
>
> v = r.getNext returns BY VALUE by means of DESTRUCTIVE COPY data that
> came through the wire, data that the client now owns as soon as getNext
> returned. There is no extra copy, no extra allocation, and the real
> thing has happened: data has been read from the outside and user code
> was made the only owner of it.

Thank you for taking the time to explain all these details. This is all 
great stuff.

L. 



More information about the Digitalmars-d-announce mailing list