Closed al6x closed 3 years ago
It would be very helpful if this RFC included more information, like more motivation. alternatives, drawbacks, etc. See the other RFCs for examples of that.
This has been requested quite often and it has been explained equally often that "reverse ranges" (a..b
where a > b
) are empty for a reason, namely that things like 0..(a.len - 1)
would silently be buggy. As another data point, Rust also has this behaviour. Apart from that, it would be a (silent) breaking change, which is yet another reason against changing this.
Additionally, this can already be achieved by using the countdown
iterator:
for i in countdown(10, 1):
echo i
While this makes sense logically, practically there are a few points against it:
Ok, closing then.
Additionally, this can already be achieved by using the countdown iterator:
There are so called Machete vs SwissKnife designs. With machete, you have simple knife that could do many things, and the more you master it the more you can do. With SwissKnife, you have a box of predefined narrow use tools and you can pick tool you need, but you can't quite combine it or master the same way.
I think this is about this situation, where you can't reuse a "Range" tool in new situation, and need to pick up another specific "countdown" tool.
Sometimes it's useful to iterate in reverse order