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

Xiaodi Wu xiaodi.wu at gmail.com
Thu Mar 31 14:47:29 CDT 2016

Yes, I've had occasion to sample every n deciRuncibles as well.
Although there are difficulties with edge cases, I think it would be
throwing out the baby with the bath water (so to speak) to forbid
striding from 1.0 to 10.0 by 0.5, which I think most users would
expect to be able to do if they can stride from 1 to 10 by 1 (and
which they can do at present, just with accumulating error).

By contrast, I really can't imagine that too many intentional use
cases would push up against any possible upper iteration limits,
whether it's 2^64 or 2^53, but the Swifty thing would be to have
predictable behavior if those limits are reached.

On Thu, Mar 31, 2016 at 1:40 PM, Erica Sadun via swift-evolution
<swift-evolution at swift.org> wrote:
> On Mar 31, 2016, at 12:29 PM, Stephen Canon via swift-evolution
> <swift-evolution at swift.org> wrote:
> I also don’t think that such a loop is particularly useful.  For
> floating-point types, something like stride(from: T, to: T, steps: Int)
> seems safer and more workable to me (this is just my immediate reaction, I
> haven’t thought this through in detail, and am likely to change my mind if
> someone makes a good case).
> While I do not object to n-steps, allowing a step difference is equally
> important in my opinion.
> "I want to sample every n deciRuncibles" versus "I want to sample 8 times
> between 1 deciRuncible
> and 10 deciRuncibles"
> I disagree that the former is less useful than the latter.
> -- E
> _______________________________________________
> 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