[swift-evolution] Feature proposal: Range operator with step

Erica Sadun erica at ericasadun.com
Tue Apr 5 18:51:51 CDT 2016

> On Apr 5, 2016, at 5:22 PM, Dave Abrahams via swift-evolution <swift-evolution at swift.org> wrote:
> I don't think that's obvious at all, because 0 ≮ 10

Points brought up elsewhere:

* A range does not have direction, it is is an area of variation between lower and upper limits.
* A range does not go from a larger amount to a smaller amount because it is not a sequence
* Much of this problem goes away with striding (as Dave pointed out several times, sorry Dave)

After consideration, I have been persuaded to the opinion that

>  stride(from: 0, to: -10, by: -1)


>    (-9...0).reverse()

both represent the numbers -9, -8,...,0 better than any alternatives I have offered. I still
prefer the stride version for intent and clarity.

That said, I also prefer my revised SE-0051 semantics for better representing what strides will
attempt to do.

-- Erica
p.s. Thanks all for the patient explanations

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160405/27aa14d1/attachment.html>

More information about the swift-evolution mailing list