Steven Schveighoffer <> changed:

           What    |Removed                     |Added
             Status|RESOLVED                    |REOPENED
                 CC|                            |
         Resolution|WONTFIX                     |
           Severity|normal                      |enhancement

--- Comment #12 from Steven Schveighoffer <> 2011-07-04 
05:44:32 PDT ---
Have to chime in to agree with Vladimir here.

foreach_reverse is such a special case (that is technically no longer useful),
that I think it should only work on arrays.

Essentially, using a delegate takes care of foreach_reverse for structs or

foreach(x; &obj.inReverse)

and retro takes care of ranges,  so all that is left is builtins.  The only two
builtin types that can be iterated are arrays and associative arrays. 
Reversing the order of iterating an associative array makes no sense at all. 
All that is left is arrays.  I agree arrays need something that currently does
not exist if we wanted to deep-six foreach_reverse, but it has no use outside
arrays.  I can't think of a single case where foreach_reverse should be used
instead of foreach on a delegate.  I'd say 100% of the time, it is an error. 
If you hear any complaining, I'll personally defend the choice :)

I'm marking this as an enhancement, as technically foreach_reverse works as
specified.  If you do not think it's worth leaving open as an enhancement
request, I'll leave it alone.  The one good thing about this 'bug' is that it's
not likely happen -- It likely happens when someone tries foreach_reverse on a
delegate, finds it doesn't do what they want, and switches it back, never to be
used again.  I'd hazard to guess that if you implemented this fix, no code will
break.  Anywhere.

If this is closed, I'll reopen for updating the documentation to say "using
foreach_reverse on a delegate does *exactly the same thing* as using foreach on
a delegate".  If it won't be fixed, at least it should be documented as
something you should never do ;)

BTW, related is bug 2498 that would make the &obj.inReverse be writable as
obj.inReverse (more pleasant to read/write):

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to