D component programming is a joke (Was: Re: Component programming)

Jonathan M Davis jmdavisProg at gmx.com
Sat Aug 3 12:10:46 PDT 2013


On Saturday, August 03, 2013 01:27:20 Timon Gehr wrote:
> Also, you may want to replace some of the manually implemented ranges
> where this makes sense.
> 
> Eg, datesInYear can be expressed more to the point as:
> 
> 
> auto datesInYear(int year){
>      return Date(year,1,1).recurrence!((a,n)=>a[n-1]+1.dur!"days")
>          .until!(a=>a.year>year);
> }

You could also use std.datetime.Interval and do something like

auto datesInYear(int year)
{
    auto interval = Interval!Date(Date(year, 1, 1), Date(year + 1, 1, 1));
    return interval.fwdRange((a){return a + dur!"days"(1);});
}

I do think that I need to revisit how ranges work with intervals in 
std.datetime, as they're a bit clunky.

- Jonathan M Davis


More information about the Digitalmars-d mailing list