[phobos] datetime review

Andrei Alexandrescu andrei at erdani.com
Sun Oct 10 06:34:34 PDT 2010


On 10/10/10 7:56 CDT, Philippe Sigaud wrote:
> On Sun, Oct 10, 2010 at 03:40, Denis<2korden at gmail.com>  wrote:
>> I believe in D one should be able to write a RangedInt(int lowerBound,
>> int upperBound) type that would make sure it contains value in the
>> range specified (that would require runtime checks, but I think that's
>> acceptable, those check can be disabled in release). Could be suitable
>> for DayOfWeek, Month, etc.
>
> What about posting that as a [challenge] on the main D newsgroup?

Good idea.

> It's also interesting for floating point values between 0 and 1, for
> probabilities or whatever field that's normalized.
> Heck, even for defining letters, digits, etc.
>
> alias Ranged!(char, 'a','z') letters;
> alias Ranged!(char, 'A', 'Z') Letters;
> alias Ranged!(char, '0', '9') digits;

Great. I still suggest using "Bounded" instead of "Ranged" to avoid 
confusion with anything range. In particular, ranges are open to the 
right but bounded are closed.


Andrei


More information about the phobos mailing list