Regarding iota
bearophile
bearophileHUGS at lycos.com
Thu Aug 19 19:30:30 PDT 2010
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
More information about the Digitalmars-d
mailing list