On 06/25/2012 07:26 PM, Mehrdad wrote:
I feel like isInfinite is useless for typical cases... the only "infinite" (perhaps I should call it "unbounded" instead?) range I've ever realistically come across is a stream, like console input or a network stream.
Console input or network streams can be terminated.
Of course, isInfinite doesn't make any sense for any type of wrapper around console input -- is it true or false? You can't tell, because it depends on whether the input is redirected. If the console input was redirected, then it would be finite, with a certain length (the length of the file). If not, then it would be infinite (er, unbounded).
Infinite lazy ranges are an useful abstraction. You could read up on Haskell. Lists in Haskell programs are often infinite.
So IMHO, we should deprecate isInfinite entirely, and instead rely on length being size_t.max.
Infinite ranges do not have a length.
Not only would it make more sense, but it would make it possible to create a random-access wrapper around an input range (like console input), which lazily fetches its data. Then you can work with console input like a regular string!
An infinite range can be buffered lazily just fine.
