digitalmars.D - Regarding iota
- bearophile (19/19) Aug 19 2010 David Simcha has kindly done work on this iota() bug:
- bearophile (3/4) Aug 20 2010 In the meantime I have reopened it, so this discussion and problem doesn...
David Simcha has kindly done work on this iota() bug:
http://d.puremagic.com/issues/show_bug.cgi?id=4603
Now iota(1, 0) produces a run-time error, this is better than before, but
coming from Python I see the usage of iota just as a loop:
So I expect this:
foreach (i; iota(1, 0)) {...}
to act as:
foreach (i; 1 .. 0) {...}
Or as:
for (int i = 1; i < 0; i++) {...}
In all three situations I expect the loop contents to just not being executed,
instead of receiving an error in just the first case.
This is also what Python range/xrange do in this case:
for in in xrange(1, 0): ...
and so far I've seen the iota() as similar to the xrange().
If foreach_reverse is scheduled for deprecation, and you have to use a:
foreach (i; retro(iota(a, b))) {}
Then I'd like it to act as foreach_reverse when the loop range intervals are
"wrong".
What do you think?
Bye,
bearophile
Aug 19 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4603In the meantime I have reopened it, so this discussion and problem doesn't get lost in the chaos. Bye, bearophile
Aug 20 2010








bearophile <bearophileHUGS lycos.com>