September 03, 2021 [Issue 22272] New: [std.range.retro] should behave the same as foreach_reverse | ||||
|---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=22272 Issue ID: 22272 Summary: [std.range.retro] should behave the same as foreach_reverse Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: normal Priority: P1 Component: phobos Assignee: nobody@puremagic.com Reporter: jlourenco5691@gmail.com The Range retro follows the current Range hierarchy. This brings friction when working with this range because it forces the user to implement a 'save' method. Iterating a retro range should be the same as iterating with a foreach_reverse. The foreach_reverse allows iterating ranges without the 'save' method implementation. I would even argue that 'popFront' and 'front' shouldn't be required because once again foreach_reverse allows that. --- struct Foo { void popBack() { i--; } bool empty() { return !i; } auto back() { return i; } int i = 1; } void main() { foreach_reverse(_; Foo.init) {} } --- -- | ||||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply