Forward ranges in Phobos v2
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.com
Wed Nov 3 15:38:18 UTC 2021
On 2021-11-02 20:18, Paul Backus wrote:
> On Wednesday, 3 November 2021 at 00:01:33 UTC, H. S. Teoh wrote:
>> The problem with manually-added tags of this sort is that people
>> forget to do it, and that leads to trouble. Preferably, it should be
>> something already implicit in the range type itself, that does not
>> require additional effort to tag.
>>
>> I'm kinda toying with the idea of struct == forward range, class ==
>> input range: the difference is inherent in the type itself and
>> requires no further effort beyond the decision to use a by-value type
>> vs. a by-reference type, which coincides with the decision to make
>> something an input range or a forward range.
>
> Having input ranges implement `next` and forward ranges implement `head`
> and `tail` would also make them easy to distinguish.
What would be the signature of next?
Would forward ranges also implement next? If not, that would mean
algorithms for input ranges won't work for forward ranges.
More information about the Digitalmars-d
mailing list