[swift-evolution] For-loop revisited
David Waite
david at alkaline-solutions.com
Fri Feb 26 14:52:37 CST 2016
> On Feb 26, 2016, at 9:07 AM, Ted F.A. van Gaalen via swift-evolution <swift-evolution at swift.org> wrote:
>
> >> Does .stride(), which in the end uses a descendant of SequenceType, just calculate a new value each time for..in.. uses .next() on this collection?
this.
> for x from xmin to xmax by xstep { }
>
> for x from xmax to xmin by -xstep { }
>
> for apple from 1 to applesInTruck { }
>
> No need for collections in these cases,
As the thread for removal of C-style for showed in benchmarks, using a range or stride does not have a performance impact under optimization. Such new syntax would need to stand on its own as a second alternative to using ranges/strides.
Considering that it would require reserving three new keywords (‘from’, ‘to’, and ‘by’) this will be a hard argument to make.
-DW
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4139 bytes
Desc: not available
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160226/f00e5400/attachment.p7s>
More information about the swift-evolution
mailing list