Ranges with length that cannot be named

Joseph Rushton Wakeling joseph.wakeling at webdrake.net
Wed Sep 18 19:27:44 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).

There is also quite a nice thing that Rust has for its iterators, 
where it defines the bounds that the length could be.  This means 
that for example one can define cases with a clear upper bound on 
length but no well defined lower bound (e.g. the results of 
applying a filter to a range), but also cases which have a clear 
_lower_ bound without defining an upper bound (which could have 
several uses, including the case described here where the length 
is guaranteed finite but larger than size_t.max).

More information about the Digitalmars-d mailing list