[swift-evolution] Rekindling: "Extending declaration scope to condition for `repeat { } while ()"

David Sweeris davesweeris at mac.com
Mon Jun 12 20:56:48 CDT 2017


> On Jun 12, 2017, at 5:13 PM, Pavol Vaskovic via swift-evolution <swift-evolution at swift.org> wrote:
> 
> On Sun, Jun 11, 2017 at 1:52 AM, Haravikk via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
> 
> With the ability to specify throwaway variables more easily, I'm sticking with my using syntax here:
> 
> var theNames:[String] = []
> while let eachItem = theIterator.next() using (var theTotal = 0) where (theTotal < 100) {
> 	theNames.append(eachItem.name)
> 	theTotal += eachItem.value
> }
> 
> Depending upon your preference on how to structure the using and where parts this is shorter and easier.
> 
> I think you just reinvented the C-style for loop, that was removed in SE-0007 <https://github.com/apple/swift-evolution/blob/master/proposals/0007-remove-c-style-for-loops.md>.
Eh, as long as a feature wasn’t removed for security or correctness reasons (which isn’t the case with SE-0007), I don’t see a problem with one proposal enabling functionality that was removed by another. It’s not like we said C-style for loops are evil or anything, just that they weren’t right for Swift. If it turns out that something which otherwise is right for Swift can be “abused” to get C-style for loop semantics, then those who voted against SE-0007 are free to try out this new syntax and see if that helps them. IMHO, anyway.

- Dave Sweeris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170612/018555d0/attachment.html>


More information about the swift-evolution mailing list