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

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Fri Aug 2 18:07:02 PDT 2013


On 2013-08-02 23:27:20 +0000, Timon Gehr said:
> 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);
> }
> 
> 
> 
> (This closes over year though. The following version uses only closed 
> lambdas by embedding year in the returned range object:
> 
> 
> auto datesInYear(int year){
>      return Date(year,1,1)
>          .recurrence!((a,n)=>a[n-1]+1.dur!"days")
>          .zip(year.repeat)
>          .until!(a=>a[0].year>a[1]).map!(a=>a[0]);
> })

Would be nice to have a couple of these both explicit and also 
implemented with the stdlib.

Andrei




More information about the Digitalmars-d mailing list