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

Erica Sadun erica at ericasadun.com
Tue Apr 5 17:30:37 CDT 2016


> On Apr 5, 2016, at 4:24 PM, Stephen Canon <scanon at apple.com> wrote:
> 
>> On Apr 5, 2016, at 3:22 PM, Erica Sadun via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>> 
>>> On Apr 5, 2016, at 4:17 PM, Dave Abrahams via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>>> 
>>> on Tue Apr 05 2016, Erica Sadun <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>>> 
>>>>   On Apr 5, 2016, at 1:54 PM, Dave Abrahams
>>>>   <dabrahams at apple.com <mailto:dabrahams at apple.com>> wrote:
>>>>   IMO this:
>>>> 
>>>>   (-9...0).reverse()
>>>> 
>>>>   is better than 
>>>> 
>>>>   stride(from: 0, to: -10, by: -1)
>>>> 
>>>>   What do you think?
>>>> 
>>>> The latter better reflects an author's actual intent. The former depends on
>>>> implementation details, which can be hazy, especially, around the edge cases. It
>>>> is quicker to read, understand, and verify that the latter is what is
>>>> meant.
>>> 
>>> Except that there seems to be some confusion over what "to:" means, right?
>> 
>> obviously (0..<-10).by(-2) would be best.
> 
> (0 ..> -10).by(-2)?
> 
> Maybe having another range operator is overkill, but ..< seems pretty bonkers here.

Suddenly SE-0051 is starting to look a lot more promising.

https://github.com/apple/swift-evolution/blob/master/proposals/0051-stride-semantics.md <https://github.com/apple/swift-evolution/blob/master/proposals/0051-stride-semantics.md>

-- E

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


More information about the swift-evolution mailing list