On 02/07/12 18:43, bearophile wrote:
It's not a bug, it's caused by how ranges like retro work. retro yields a single
item. In D you can't overload on return values, so foreach can't try to call a
second retro.front overload that yields an (index,item) tuple (that later
foreach is able to unpack on the fly) instead of the retro.front that just
yields the item.
Ahh, OK. Clear, just a little surprising.
To solve that problem this is what I have suggested to add to Phobos:
http://d.puremagic.com/issues/show_bug.cgi?id=5550
Looks like a nice idea!
The reason I was interested was because of a case where a foreach_reverse was
called for across an array, but where it was useful to flip the indices as well.