The new, new phobos sneak preview

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Fri Apr 10 17:32:52 PDT 2009


bearophile wrote:
> Andrei Alexandrescu:
> 
>> Then please vote up my comment which shows a solution that is simple 
>> *and* efficient :o).
> 
> I am not registered there, so I can't vote, I guess.
> Generally I don't like reduce() HOF, because it generally leads to less readable code (and often people use it only to compute a sum or product of items), but this time it's a good enough usage.
> You have forgotten to compute the average, as requested by the original article.
> 
> Regarding field access:
> assert(r.field[0] == 2); // minimum
> assert(r.field[1] == 11); // maximum
> I've found that sometimes a shorter syntax is nice, I use d0, d1, etc:
> assert(r.d0 == 2);
> assert(r.d1 == 11);
> (It doesn't replace the general [] access).

Yah, I had _0 but removed it. The plan is to use alias this to get rid 
of field altogether so you write r[0], r[1] etc. but it turns out alias 
this still has a few bugs.


Andrei



More information about the Digitalmars-d mailing list