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

Dave Abrahams dabrahams at apple.com
Wed Apr 6 11:04:51 CDT 2016

on Tue Apr 05 2016, Xiaodi Wu <xiaodi.wu-AT-gmail.com> wrote:

> I think my opinion is largely the same. A range is not a stride, 

I don't think anyone on this thread has suggested they could be
considered the same... until just now.

> and sometimes we have use for striding backwards, a use case that
> shouldn't be penalized. +1 to the free function.
> I wouldn't mind, orthogonally, a way to express (a, b] as a range. It
> just seems like that should be of use, somewhere.

But that's not a strong enough reason to add it to the standard library.

> Finally, orthogonal to all of the above, I'm super eager to end error
> accumulation in floating point strides.

Looking forward to those results, too!

> On Tue, Apr 5, 2016 at 6:52 PM Erica Sadun via swift-evolution
> <swift-evolution at swift.org> wrote:
>         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)
>     and 
>         (-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
>     _______________________________________________
>     swift-evolution mailing list
>     swift-evolution at swift.org
>     https://lists.swift.org/mailman/listinfo/swift-evolution


More information about the swift-evolution mailing list