Joseph Rushton Wakeling:
It's slightly annoying that one can't readily get immutability
to play nice with more general iterations than i .. j.
For example if you consider the loop,
for (i = 10; i > 0; --i) { ... }
Thankfully foreach_reverse was not deprecated:
void main() {
import std.stdio;
for (auto i = 10; i > 0; --i)
write(i, " ");
writeln;
foreach_reverse (immutable i; 1 .. 11)
write(i, " ");
writeln;
}
[* Hijacking of discussion: a while back I think I floated the
idea of generalizing iota() with closed/open boundary
conditions similar to those found in std.random.uniform; so
e.g. you could do iota!"[]"(0, 10) and the upper bound would be
included in the values returned. Would be useful for cases
like these.]
Yes, it's a kind of necessary enhancement:
http://d.puremagic.com/issues/show_bug.cgi?id=10466
Bye,
bearophile