Range Redesign: Empty Ranges
Paul Backus
snarwin at gmail.com
Wed Mar 6 14:18:50 UTC 2024
On Monday, 4 March 2024 at 21:29:40 UTC, Jonathan M Davis wrote:
> 2. The range API provides no way (other than fully iterating
> through a range) to get an empty range of the same type from a
> range unless the range is a random-access range.
Genuine question: what are the use-cases for this?
In general, the capabilities of ranges are designed to serve the
needs of algorithms. Input ranges exist because single-pass
iteration is all that's needed to implement algorithms like map,
filter, and reduce. Random-access ranges exist because they're
needed for sorting algorithms. And so on.
I'm not aware of any algorithm, or class of algorithm, that needs
this specific capability you're describing. If such algorithms
exist, we should be using them to guide our design here. If they
don't...then maybe this isn't really a problem at all.
More information about the Digitalmars-d
mailing list