Bug 6251 – D spec should warn about using foreach_reverse on a delegate
Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P2
Component
dlang.org
Product
D
Version
D2
Platform
All
OS
All
Creation time
2011-07-05T04:00:00Z
Last change time
2015-06-09T05:11:39Z
Keywords
pull, spec
Assigned to
nobody
Creator
schveiguy
Comments
Comment #0 by schveiguy — 2011-07-05T04:00:17Z
Currently, foreach_reverse on a delegate is equivalent to using foreach on a delegate. A novice user might expect foreach_reverse to somehow force the delegate to iterate its elements in reverse. In order to prevent more bugs being filed on this issue, the documentation should specifically identify that foreach_reverse on a delegate does not reverse the order of iteration, and so should not be used.
This is related to bug 1553
Comment #1 by smjg — 2011-07-08T15:05:39Z
It took me a moment to make sense of it. So it basically calls the delegate applied to the body of the foreach statement in the same way as foreach (element; object) calls the object's opApply on the body of the foreach statement?
On this basis, surely foreach_reverse over a delegate should be just illegal?
Comment #2 by issues.dlang — 2011-07-08T15:19:55Z
Bug# 1553
Comment #3 by yao.gomez — 2012-02-06T13:05:24Z
In the comments of issue 1553 there are an initiative to add documentation about this issue.
*** This issue has been marked as a duplicate of issue 1553 ***
Comment #4 by schveiguy — 2012-02-06T13:48:43Z
(In reply to comment #3)
> In the comments of issue 1553 there are an initiative to add documentation
> about this issue.
This is *not* a duplicate, it's a direct result of Walter closing bug 1553 saying updating the documentation should be fine. This bug report *is* the initiative to add documentation!