Do infinite bidirectional ranges make any sense?

Jonathan M Davis jmdavisProg at gmx.com
Sat Aug 11 21:11:48 PDT 2012


As far as I can tell, there's nothing technically stopping an infinite range 
from being bidirectional, but I can't think of any case where such a range 
makes any sense at all.

isRandomAccessRange is written specifically to allow infinite forward ranges be 
random access without being bidirectional (unlike non-infinite random-access 
ranges which must be bidirectional). But I don't see anything else which 
either supports or stops infinite ranges from being bidirectional.

I'm working on creating a small testing framework for ranges so that it's easy 
to generate the exact range type that you want (with regards to both the type 
of range - forward, random-access etc. - as well as other attributes of the 
range such as hasLength and hasSlicing), and I can't decide whether I should 
make it possible for it to generate infinite bidirectional ranges or not. If 
there are truly zero use cases where they make any sense, then I see no point 
in coding for them, but if they _are_ possible and reasonable, then I need to 
take them into account.

Can anyone think of any situation where an infinite bidirectional range would 
make any sense at all?

- Jonathan M Davis


More information about the Digitalmars-d mailing list