Range Redesign: Empty Ranges

Dom DiSc dominikus at scherkl.de
Tue Mar 5 14:39:17 UTC 2024


On Monday, 4 March 2024 at 21:29:40 UTC, Jonathan M Davis wrote:
> Of course, if you're dealing with an infinite range, then there 
> can't be a way to make it empty, but IMHO, we should have a way 
> to get an empty range from an arbitrary finite range type where 
> the empty range is of the same type. And for that, I see three 
> possibly options:
>
> 1. Make it so that for finite ranges, the init value of a range 
> is required to not just be valid, but it's also required to be 
> empty.

I think this is the best solution.

> A related issue is that if we're removing save from forward 
> ranges, [...] Adding emptyRange or makeEmpty [...] wouldn't 
> actually fix the problem. Some old basic input ranges which are 
> infinite would still pass the new isForwardRange.

Are there infinite ranges that are indeed not forward ranges?
I mean - they produce their output somehow algorithmically.
Should be possible to safe the state of such an algorithm, no?
Ok, maybe someone has not implemented it, but as we are requiring 
things anyway, why not require an infinite range to implement the 
copy function?



More information about the Digitalmars-d mailing list