foreach_reverse is better than ever

dsimcha dsimcha at yahoo.com
Sun Feb 14 06:49:58 PST 2010


== Quote from Daniel Murphy (yebbliesnospam at gmail.com)'s article
> Andrei Alexandrescu Wrote:
> > Gone, that is. Walter agreed to remove it.
> >
> > To achieve the functionality of
> >
> > foreach_reverse (r) { ... }
> >
> > use
> >
> > foreach (retro(r)) { ... }
> >
> > using retro in std.range.
> >
> >
> > Andrei
> What about where foreach is being done over something other than a range?
> eg.
> foreach(i; 1..100)
> foreach(v; structwithopapply)

In general, now that we've decided to keep opApply, std.range needs to be reworked
a little to make it coexist as peacefully as possible with ranges.  For this case,
I guess retro could simply have an opApply method that forwards to
structwithopapply's opApplyReverse method.



More information about the Digitalmars-d mailing list