foreach, an analogy

Walter Bright newshound at digitalmars.com
Thu Oct 19 12:34:23 PDT 2006


Bruno Medeiros wrote:
> As of DMD now, the only advantage in 'foreach_reverse' is ephemerous: it 
> allows efficient reverse iteration of arrays.

That's the most important use case.

> But couldn't the compiler 
> easily detect this:
>   foreach(Foo f; &fooarray.opApplyReverse) { ...
> and and compile it as if it were a:
>   foreach_reverse(Foo f; fooarray) { ...

Yes, it could. But it looks like a hack. A little syntactic sugar makes 
a big difference.



More information about the Digitalmars-d-announce mailing list