D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6251 - D spec should warn about using foreach_reverse on a delegate
Summary: D spec should warn about using foreach_reverse on a delegate
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dlang.org (show other issues)
Version: D2
Hardware: All All
: P2 enhancement
Assignee: No Owner
URL:
Keywords: pull, spec
Depends on:
Blocks:
 
Reported: 2011-07-05 04:00 UTC by Steven Schveighoffer
Modified: 2015-06-09 05:11 UTC (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Steven Schveighoffer 2011-07-05 04:00:17 UTC
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 Stewart Gordon 2011-07-08 15:05:39 UTC
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 Jonathan M Davis 2011-07-08 15:19:55 UTC
Bug# 1553
Comment 3 Yao Gomez 2012-02-06 13:05:24 UTC
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 Steven Schveighoffer 2012-02-06 13:48:43 UTC
(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 Yao Gomez 2012-02-06 13:59:40 UTC
Ah OK. Apologies.
Comment 7 github-bugzilla 2014-09-10 11:58:35 UTC
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.