Marc Schütz:
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);
I see. In my post I have explained why this is a bad idea (it's
not explicit so it gives confusion, and it complicates the
language/compiler).
A better design is to remove the auto-indexing feature for arrays
too, and use .enumerate in all cases, as in Python.
Bye,
bearophile