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

Erica Sadun erica at ericasadun.com
Wed Apr 6 15:40:32 CDT 2016


> On Apr 6, 2016, at 2:35 PM, Erica Sadun via swift-evolution <swift-evolution at swift.org> wrote:
> 
> Yes, but you can with warnings and fixits. 
> 
> * The compiler should issue a warning for any use of 
> 
> (n..<m).striding(by: v | v < 0) | n, m, v : Integer
> 
> with a fixit of "replace  (n..<m) with (n...m - 1)" regardless of
> whether n or m is known at compile time 
> 
> * If v cannot be known at compile time, I think the compiler should
> always prefer ... to ..<.
> 
> * The compiler should not allow
> 
> (n..<m).striding(by: v | v < 0) | n, m, v: floating point types
> 
> where v is known at compile time to be a negative constant. There should 
> also be a runtime precondition that raises a fatal error should a negative 
> v be used with a half-open interval.
> 
> -- E

Following up to myself, this can easily be expanded to the other cases just
brought up by Xiaodi Wu

-- E


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160406/87d1bddc/attachment.html>


More information about the swift-evolution mailing list