foreach_reverse error
Steven Schveighoffer
schveiguy at yahoo.com
Fri May 11 05:27:58 PDT 2012
On Fri, 11 May 2012 03:43:53 -0400, mta`chrono
<chrono at mta-international.net> wrote:
>>> group returns a lazy forward range. use foreach(i; group(retro(ints)))
>>
>> Yet another reason foreach_reverse needs to go.
>>
>>
>> T
>>
>
> No please don't! There are hundred and ten very usefull cases.
No, there is only one.
foreach_reverse(i; 0..10) {...}
Every other usage of foreach_reverse can be rewritten with foreach.
I would argue that this should work:
foreach(i; 10..0)
but it would be quite odd given that you would start with 9 and end with
0. I don't have a really good answer for this, foreach(i; 9..-1) isn't
really acceptable, especially if i is unsigned.
-Steve
More information about the Digitalmars-d-learn
mailing list