std.v2020.algorithm etc[ WAS: Is run.d going to be expand for runtime and the phobos library?]

Paul Backus snarwin at gmail.com
Sat Jun 20 19:35:07 UTC 2020


On Saturday, 20 June 2020 at 19:23:55 UTC, Jon Degenhardt wrote:
> On Saturday, 20 June 2020 at 18:26:43 UTC, Steven Schveighoffer 
> wrote:
>> But the larger point is that true input-only ranges are rare. 
>> The only problem is for classes, since you cannot invoke a 
>> copy constructor on those.
>
> Interesting discussion. Could you expand on this comment? 
> Several people have mentioned this.
>
> I write my own input ranges somewhat regularly. I've never had 
> the need to make them forward ranges. However, the typical 
> reason for creating a range is because I have application 
> specific data that I want to iterate over (and usually 
> construct) lazily. Input ranges are very convenient way to do 
> this. I do end up making many of them reference ranges though.
>
> So, I'm wondering if its really that input-only ranges are 
> rare, or if it's that the number of algorithms that can be used 
> on input-only ranges is small. Or perhaps I'm not quite 
> grokking the distinction between a "true" input-only range and 
> one that satisfies isInputRange, but none of the other range 
> primitive tests.
>
> --Jon

Could you easily make your ranges into forward ranges if you 
wanted to? That is, if you copy one of them, and then iterate the 
original, does the copy remain valid? If so, they're not "true" 
input ranges.

A "true" input range is something like a file handle, where you 
couldn't implement `save` even if you wanted to--iterating one 
copy automatically invalidates all the others.


More information about the Digitalmars-d mailing list