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!
Comment #5 by yao.gomez — 2012-02-06T13:59:40Z
Ah OK. Apologies.
Comment #6 by hsteoh — 2014-09-10T11:43:55Z
Comment #7 by github-bugzilla — 2014-09-10T11:58:35Z
Commits pushed to master at https://github.com/D-Programming-Language/dlang.org https://github.com/D-Programming-Language/dlang.org/commit/52c00a22c74e3bfb5be9cbd4c6549b9e8cbdc45f Fix issue 6251: docs should warn about foreach_reverse over delegate. https://github.com/D-Programming-Language/dlang.org/commit/1e29f79e6577a3d0f32fcc36f7de1a438286985d Merge pull request #647 from quickfur/bug6251 Fix issue 6251: docs should warn about foreach_reverse over delegate.
Comment #8 by github-bugzilla — 2015-02-18T03:40:14Z