June 28, 2013 [Issue 8155] Deprecate std.range.lockstep | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=8155 --- Comment #10 from Joseph Rushton Wakeling <joseph.wakeling@webdrake.net> 2013-06-28 13:21:31 PDT --- (In reply to comment #9) > Let me add a note. For your specific use case it's better to use enumerate(), > from Issue 5550 : > > auto arr1 = new double[10]; > foreach (i, ref x; arr1.enumerate) > x = i; > arr1.writeln; Thanks for the useful hint :-) In fact in the general case where I discovered this issue, the use case was more, foreach(i, ref x; lockstep(arrIndex, arr1)) x = i; ... where arrIndex does not _necessarily_ contain the sequence 0, 1, 2, 3, 4, ... -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
June 28, 2013 [Issue 8155] Deprecate std.range.lockstep | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=8155 --- Comment #11 from bearophile_hugs@eml.cc 2013-06-28 13:57:42 PDT --- (In reply to comment #10) > Thanks for the useful hint :-) In fact in the general case where I discovered this issue, the use case was more, > > foreach(i, ref x; lockstep(arrIndex, arr1)) > x = i; > > ... where arrIndex does not _necessarily_ contain the sequence 0, 1, 2, 3, 4, ... Such cases are better solved using the copy() algorithm. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
June 28, 2013 [Issue 8155] Deprecate std.range.lockstep | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=8155 --- Comment #12 from Joseph Rushton Wakeling <joseph.wakeling@webdrake.net> 2013-06-28 15:51:51 PDT --- (In reply to comment #11) > Such cases are better solved using the copy() algorithm. I accept the point, but I still think that the code given shouldn't fail with zip. In my real application, the value of x was determined by some rather complex calculations for which i was a parameter, so copy doesn't work either ... :-) -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
June 29, 2013 [Issue 8155] Deprecate std.range.lockstep | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=8155 --- Comment #13 from bearophile_hugs@eml.cc 2013-06-28 17:18:28 PDT --- (In reply to comment #12) > In my real application, the value of x was determined by some rather complex calculations for which i was a parameter, so copy doesn't work either ... :-) I see, for that I sometimes use a pattern like this: import std.stdio, std.array, std.algorithm; int calculations(TP)(TP ix) pure nothrow { return ix[1] ^^ 2 + ix[0]; } void main() { auto arr = [10, 20, 30]; arr.enumerate.map!calculations.copy(arr); arr.writeln; } If calculations() is pure and slow, then perhaps it's worth using a amap from std.parallelism (but I don't know how well it interacts with the copy). -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
June 29, 2013 [Issue 8155] Deprecate std.range.lockstep | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=8155 --- Comment #14 from Joseph Rushton Wakeling <joseph.wakeling@webdrake.net> 2013-06-29 02:48:35 PDT --- (In reply to comment #13) > I see, for that I sometimes use a pattern like this: Very cool! :-) Nevertheless, I think deprecating lockstep in favour of zip is a no-no unless one can do a systematic replace, 's/lockstep/zip/' and have the new code Just Work. Glancing through the code, it looks like an issue of design difference rather than a bug per se. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
June 29, 2013 [Issue 8155] Deprecate std.range.lockstep | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=8155 --- Comment #15 from Joseph Rushton Wakeling <joseph.wakeling@webdrake.net> 2013-06-29 02:50:34 PDT --- (In reply to comment #14) > Glancing through the code, it looks like an issue of design difference rather than a bug per se. The docs note that std.range.zip "offers mutation and swapping if all ranges offer it". Hence the problem if one of the ranges is e.g. iota(), rather than iota().array(). -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
June 29, 2013 [Issue 8155] Deprecate std.range.lockstep | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=8155 --- Comment #16 from bearophile_hugs@eml.cc 2013-06-29 03:16:46 PDT --- (In reply to comment #14) > I think deprecating lockstep in favour of zip is a no-no unless > one can do a systematic replace, 's/lockstep/zip/' and have the new code Just > Work. If not already present I suggest you to open an enhancement request that asks for your improvement of zip, and then we'll make this issue dependant to the other one. They are two separate issues. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
July 04, 2013 [Issue 8155] Deprecate std.range.lockstep | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=8155 --- Comment #17 from Joseph Rushton Wakeling <joseph.wakeling@webdrake.net> 2013-07-04 03:10:53 PDT --- (In reply to comment #16) > If not already present I suggest you to open an enhancement request that asks for your improvement of zip, and then we'll make this issue dependant to the other one. They are two separate issues. Done: Issue #10541. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation