On 10.12.2010 23:42, Steven Schveighoffer wrote:
On Fri, 10 Dec 2010 15:21:38 -0500, Jonathan M Davis
<jmdavisp...@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.
As potential user, of course, I would like this improvement, I sure
others will too.
When I looked at the code, I didn't pay much attention to the range
stuff.
I have an impression many readers didn't managed to get there with a
fresh mind :)
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);
Yes, that's even better, and, in fact, simple.
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 ;)
I like that dream, maybe start sort of contest on the most convenient
and terse notations ?
-Steve
--
Dmitry Olshansky