digitalmars.D - foreach_reverse and lockstep.
- Sean Campbell (2/2) Mar 30 2016 Why doesn't reverse iteration of lockstep work? It does for zip.
- ZombineDev (11/13) Mar 31 2016 Lockstep is actually not a range. It overloads the opApply[1]
- Jack Stouffer (2/4) Mar 31 2016 Please file an enhancement request at issues.dlang.org
- Jonathan M Davis via Digitalmars-d (13/15) Apr 01 2016 Glancing over the code quickly, it looks like lockstep doesn't actually
- Simen Kjaeraas (6/8) Apr 01 2016 Actually, it exists and it works. It's just not implemented for
- ZombineDev (2/10) Apr 01 2016 I'm already working on a PR. I think I can be ready by tomorrow.
- ZombineDev (2/15) Apr 01 2016 https://issues.dlang.org/show_bug.cgi?id=15860
- Simen Kjaeraas (5/18) Apr 01 2016 Sure, but mine's ready now :p
Why doesn't reverse iteration of lockstep work? It does for zip. Is this intended or is it a bug?
Mar 30 2016
On Thursday, 31 March 2016 at 03:12:34 UTC, Sean Campbell wrote:Why doesn't reverse iteration of lockstep work? It does for zip. Is this intended or is it a bug?Lockstep is actually not a range. It overloads the opApply[1] operator to support foreach. To support foreach_reverse, it would also have to override opApplyReverse. I'd say that it's not a bug but still a valid enhancement request. BTW the upcomming release has better documentation on the differences between lockstep [2] and zip [3]. [1]: https://github.com/D-Programming-Language/phobos/blob/master/std/range/package.d#L4153 [2]: http://dlang.org/phobos-prerelease/std_range#lockstep [3]: http://dlang.org/phobos-prerelease/std_range#zip
Mar 31 2016
On Thursday, 31 March 2016 at 03:12:34 UTC, Sean Campbell wrote:Why doesn't reverse iteration of lockstep work? It does for zip. Is this intended or is it a bug?Please file an enhancement request at issues.dlang.org
Mar 31 2016
On Thursday, March 31, 2016 03:12:34 Sean Campbell via Digitalmars-d wrote:Why doesn't reverse iteration of lockstep work? It does for zip. Is this intended or is it a bug?Glancing over the code quickly, it looks like lockstep doesn't actually generate a range but an object that defines opApply so that it can be used in a foreach loop but not in general range-based algorithms. IIRC, it used to be that opApply worked with foreach_reverse but did exactly the same thing as foreach, so it was made an error to use it with foreach_reverse rather than having the buggy behavior persist and confuse folks (you'd need some sort of opApplyReverse function to go with foreach_reverse, and no such thing exists). zip, on the other hand, generates an actual range, and if the ranges that it's given are bidirectional ranges, then it too will be a bidirectional range, and it'll work with foreach_reverse via the back and popBack functions. - Jonathan M Davis
Apr 01 2016
On Friday, 1 April 2016 at 14:37:36 UTC, Jonathan M Davis wrote:(you'd need some sort of opApplyReverse function to go with foreach_reverse, and no such thing exists).Actually, it exists and it works. It's just not implemented for lockstep. I'm trying to clean up my Phobos repo so I can make a PR to fix this. Apparently I need to learn more git. :) -- Simen
Apr 01 2016
On Friday, 1 April 2016 at 16:10:01 UTC, Simen Kjaeraas wrote:On Friday, 1 April 2016 at 14:37:36 UTC, Jonathan M Davis wrote:I'm already working on a PR. I think I can be ready by tomorrow.(you'd need some sort of opApplyReverse function to go with foreach_reverse, and no such thing exists).Actually, it exists and it works. It's just not implemented for lockstep. I'm trying to clean up my Phobos repo so I can make a PR to fix this. Apparently I need to learn more git. :) -- Simen
Apr 01 2016
On Friday, 1 April 2016 at 17:44:40 UTC, ZombineDev wrote:On Friday, 1 April 2016 at 16:10:01 UTC, Simen Kjaeraas wrote:https://issues.dlang.org/show_bug.cgi?id=15860On Friday, 1 April 2016 at 14:37:36 UTC, Jonathan M Davis wrote:I'm already working on a PR. I think I can be ready by tomorrow.(you'd need some sort of opApplyReverse function to go with foreach_reverse, and no such thing exists).Actually, it exists and it works. It's just not implemented for lockstep. I'm trying to clean up my Phobos repo so I can make a PR to fix this. Apparently I need to learn more git. :) -- Simen
Apr 01 2016
On Friday, 1 April 2016 at 17:44:40 UTC, ZombineDev wrote:On Friday, 1 April 2016 at 16:10:01 UTC, Simen Kjaeraas wrote:Sure, but mine's ready now :p https://github.com/D-Programming-Language/phobos/pull/4138 -- SimenOn Friday, 1 April 2016 at 14:37:36 UTC, Jonathan M Davis wrote:I'm already working on a PR. I think I can be ready by tomorrow.(you'd need some sort of opApplyReverse function to go with foreach_reverse, and no such thing exists).Actually, it exists and it works. It's just not implemented for lockstep. I'm trying to clean up my Phobos repo so I can make a PR to fix this. Apparently I need to learn more git. :) -- Simen
Apr 01 2016