ideas about ranges

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Fri May 22 18:22:55 PDT 2009


Steven Schveighoffer wrote:
> On Fri, 22 May 2009 17:10:45 -0400, Andrei Alexandrescu 
> <SeeWebsiteForEmail at erdani.org> wrote:
> 
>> Steven Schveighoffer wrote:
>>> I'm concentrating mostly on usages with foreach, not algorithms.  If 
>>> we are to have streams that fit into the range model, then they need 
>>> to be foreach'able.  I don't know that they need a lot of support to 
>>> feed into std.algorithm as reference data.  I.e. you aren't going to 
>>> sort a network stream.
>>
>> Plenty of algorithms work on input ranges.
>>
> 
> I'm confused, by input range you mean a stream?  Because I'm operating 
> under the assumption that an input range is anything that defines front, 
> popFront, and empty.  While you can shoehorn a stream into being an 
> input range, they don't necessarily implement the required elements 
> easily.  We may be confusing terminology.
> 
> Can you name an example of an input range that is a stream, and an 
> algorithm that mutates the stream in place (thereby requiring ref 
> elements)?

There isn't. All I'm saying is, we have the following constraints:

1. Any range should be seamlessly and efficiently used as an input 
range. This probably entails return by ref for efficiency.

2. Input ranges should define popNext to do at the same time reading, 
testing for empty, and advancing.

That's it!


Andrei



More information about the Digitalmars-d mailing list