[phobos] Problem with definition of isInfinite(Range)
Jonathan M Davis
jmdavisprog at gmail.com
Sun Sep 5 17:58:16 PDT 2010
Okay. If I understand correctly, as it stands, a range type is either infinite or
its not, and it's known at compile-time whether it's infinite or not. This
appears to be done by checking for a static property empty of type bool which is
known at compile-time. The question is do we _need_ to know at compile-time
whether a range is infinite? Or it would it be possible to make it so that that
can be determined at runtime?
My guess is that the algorithms that care need to know at compile-time, but if
that's the case, it poses a definite problem for me.
I have been working on a date/time module for potential inclusion in Phobos.
Part of that includes a time interval which represents a period of time starting
at one point of time and extending to another point of time which is not
included in the interval. So, for example [2010-07-04 - 2010-08-03). I'm working
on creating ranges to iterate over a time interval. The problem is that an
interval can be infinite, but you don't know at compile time whether it's
infinite. You could have an interval such as [2010-07-04 - positive infinity), and
a range over that interval would be infinite. However, whether a given interval
(and thus its range) is infinite depends on the runtime arguments that created
the interval. So, I have no way of creating an infinite range for which
isInfinite(Range) will return true.
Would it be reasonable to make it possible to have infinite ranges which were
determined to be infinite at runtime rather than compile-time? Or is there a
better solution? Or is it simply tough luck, and the range may be effectively
infinite but can't be treated that way by algorithms using isInfinite(Range)?
- Jonathan M Davis
More information about the phobos
mailing list