On Friday, 14 February 2014 at 17:42:53 UTC, bearophile wrote:
Isn't this discussion about adding an index to a range? If it
is, then I have shown why adding it in the language is a bad
idea.
As far as I understand it, it's about adding an index to
_foreach_, as is already supported for arrays:
foreach(v; [1,2,3,4])
writeln(v);
foreach(i, v; [1,2,3,4])
writeln(i, " => ", v);
But for ranges, the second form is not possible:
foreach(v; iota(4)) // ok
writeln(v);
foreach(i, v; iota(4)) // Error: cannot infer argument
types
writeln(i, " => ", v);