digitalmars.D - Different loops bug
- bearophile (38/38) Mar 01 2013 This is derived from part of a D.learn post, maybe it's of your
- Timon Gehr (2/4) Mar 01 2013 They are not different.
- bearophile (4/5) Mar 01 2013 Really? Sorry, I don't understand.
- Timon Gehr (2/7) Mar 01 2013 According to the spec the two outputs are the same.
- Brad Anderson (4/14) Mar 01 2013 Are you saying they should output the same or that they are the
- Timon Gehr (3/17) Mar 01 2013 With a correct implementation of the language, the outputs are the same....
- bearophile (5/6) Mar 01 2013 I have filed this:
This is derived from part of a D.learn post, maybe it's of your interest. This program shows two similar versions of the same loop: import std.stdio, std.algorithm, std.typetuple, std.range; void main() { auto items = [[10, 20], [30]]; foreach (_; 0 .. 2) { foreach (sub; items) { iota(sub.length) .map!((i){ writeln(sub); return 0; }) .array(); } } writeln(); foreach (_; TypeTuple!(0, 1)) { foreach (sub; items) { iota(sub.length) .map!((i){ writeln(sub); return 0; }) .array(); } } } Its output: [10, 20] [10, 20] [30] [10, 20] [10, 20] [30] [10, 20] [10, 20] [30] [30] [30] [30] Do you see why the output of the two foreach(_) is different? Bye, bearophile
Mar 01 2013
On 03/01/2013 11:07 PM, bearophile wrote:... Do you see why the output of the two foreach(_) is different?They are not different.
Mar 01 2013
Timon Gehr:They are not different.Really? Sorry, I don't understand. Bye, bearophile
Mar 01 2013
On 03/02/2013 12:23 AM, bearophile wrote:Timon Gehr:According to the spec the two outputs are the same.They are not different.Really? Sorry, I don't understand. Bye, bearophile
Mar 01 2013
On Friday, 1 March 2013 at 23:25:31 UTC, Timon Gehr wrote:On 03/02/2013 12:23 AM, bearophile wrote:Are you saying they should output the same or that they are the same? You and I have a different definition of "same" if the latter.Timon Gehr:According to the spec the two outputs are the same.They are not different.Really? Sorry, I don't understand. Bye, bearophile
Mar 01 2013
On 03/02/2013 01:17 AM, Brad Anderson wrote:On Friday, 1 March 2013 at 23:25:31 UTC, Timon Gehr wrote:With a correct implementation of the language, the outputs are the same. Bugs should go to the bug tracker.On 03/02/2013 12:23 AM, bearophile wrote:Are you saying they should output the same or that they are the same? You and I have a different definition of "same" if the latter.Timon Gehr:According to the spec the two outputs are the same.They are not different.Really? Sorry, I don't understand. Bye, bearophile
Mar 01 2013
Timon Gehr:According to the spec the two outputs are the same.I have filed this: http://d.puremagic.com/issues/show_bug.cgi?id=9628 Bye, bearophile
Mar 01 2013