H. S. Teoh:

Modifying the loop variable of a foreach is, in general, a risky move.

Right. In my opinion D programmers should learn that this is the preferred idiom of using foreach ranged loops:

foreach (immutable i; 0 .. n) {}

If a D programmers really needs to modify the index inside the loop body, then it's better to use a for() loop, that makes it much more explicit and clear what's happening.

Bye,
bearophile

Reply via email to