Ranges with length that cannot be named
someone at something.org
Thu Sep 19 05:30:23 UTC 2019
On Wednesday, 18 September 2019 at 19:21:23 UTC, John Colvin
> Maybe I'm misunderstanding, but are you missing that you can
> just not define the length member? Then your range doesn't have
> a defined length (it might be infinite, it might be length 0,
> it might 2*ulong.max).
Yes and no. We, in the real world, know, that the range is
finite. And in most cases, we also know, that the range has more
than 0 elements. But either it's too long (e.g. 2*ulong.max as
you write) or the computation is too complex to calculate the
length in reasonable time.
The problem is, that we cannot just leave length undefined,
making it a non random access range, because in most situations
length is needed.
Should iota have length or not? Obviously, the first three
versions should have length, and it's more likely, that they will
appear in applications. But the fourth is too long. It wouldn't
justify to remove the length property from iota, just because
this fourth one has no "defined length". And the question is,
what to do.
More information about the Digitalmars-d