Please vote on std.datetime

Steven Schveighoffer schveiguy at yahoo.com
Fri Dec 10 12:42:56 PST 2010


On Fri, 10 Dec 2010 15:21:38 -0500, Jonathan M Davis <jmdavisProg at gmx.com>  
wrote:

>
> Would it be better if I changed the IRange functions so that rather than
> returning a delegate, they took an interval and returned the range? So,  
> rather
> than
>
> auto interval = Interval!Date(Date(2010, 9, 2), Date(2010, 9, 27));
> auto func = IRange.everyDayOfWeek!Date(DayOfWeek.fri);
> auto range = interval.fwdRange(func);
>
>
> you'd get something like
>
> auto interval = Interval!Date(Date(2010, 9, 2), Date(2010, 9, 27));
> auto range = IRange.everyDayOfWeek!Date(interval, DayOfWeek.fri);
>
> Then you wouldn't have to give the IRange function Direction.fwd or
> Direction.bwd (well, just Direction.bwd, since fwd is the default) then  
> pass
> that it to fwdRange() or bwdRange() and have to worry about whether you  
> screwed
> up and mismatched the directions. It would then be caught at compile  
> time rather
> than runtime.
>
> fwdRange() and bwdRange() would stay the same, but you wouldn't have to  
> call the
> directly unless you were writing your own delegate.
>
> Does that seem like a big improvement to you? After thinking of about the
> problem further and coming up with that change, I'm definitely  
> considering making
> it.

When I looked at the code, I didn't pay much attention to the range stuff.

But you really need to incorporate IFTI here.  It would be much nicer if  
you did:

auto ival = interval(Date(2010, 9, 2), Date(2010, 9, 27);
auto range = everyDayOfWeek(ival, DayOfWeek.fri);

At least that's a start, we should be able to build more wrappers to  
reduce the verbosity:.

auto range = everyDayOfWeek(Date(2010, 9, 2), Date(2010, 9, 27),  
DayOfWeek.fri);

Some way to use slice syntax might be nice.  perhaps:

auto range = Date["9/2/2010".."9/27/2010"].every(DayOfWeek.fri);

maybe that last one is just a pipe dream ;)

-Steve


More information about the Digitalmars-d mailing list