[swift-evolution] C-style For Loops

Kevin Ballard kevin at sb.org
Thu Dec 3 18:52:45 CST 2015


Every time I've tried to use a C-style for loop, I've ended up switching
to a while loop because my iteration variable ended up having the wrong
type (e.g. having an optional type when the value must be non-optional
for the body to execute). The Postmates codebase contains no instances
of C-style for loops in Swift.

-Kevin Ballard

On Thu, Dec 3, 2015, at 04:50 PM, Eric Chamberlain wrote:
> We’ve developed a number of Swift apps for various clients over the
> past year and have not needed C style for loops either.
>
>
> --
> Eric Chamberlain, Lead Architect - iOS ArcTouch - App
> Development Studio
>
> Custom apps for world-class brands and the Fortune 500
> arctouch.com/work | arctouch.com/blog
>
>
>
>
>> On Dec 3, 2015, at 3:46 PM, Andy Matuschak
>> <andy at andymatuschak.org> wrote:
>>
>> Just checked; ditto Khan Academy.
>>
>>> On Dec 3, 2015, at 3:43 PM, Keith Smiley <keithbsmiley at gmail.com>
>>> wrote:
>>>
>>> For what it's worth we don't have a single C style for loop in the
>>> Lyft codebase.
>>>
>>> --
>>> Keith Smiley
>>>
>>> On 12/03, Douglas Gregor wrote:
>>>>
>>>>> On Dec 3, 2015, at 3:32 PM, Erica Sadun <erica at ericasadun.com>
>>>>> wrote:
>>>>>
>>>>> Does Swift still needs C-style for loops with conditions and
>>>>> incrementers?
>>>>>
>>>>> <Screen Shot 2015-12-03 at 4.30.15 PM.png>
>>>>>
>>>>> More Swift-like construction is already available with for-in-
>>>>> statements and stride. This would naturally starve the most common
>>>>> point for -- and ++ operators as well.
>>>>
>>>> My intuition *completely* agrees that Swift no longer needs C-style
>>>> for loops. We have richer, better-structured looping and functional
>>>> algorithms. That said, one bit of data I’d like to see is how often
>>>> C-style for loops are actually used in Swift. It’s something a
>>>> quick crawl through Swift sources on GitHub could establish. If the
>>>> feature feels anachronistic and is rarely used, it’s a good
>>>> candidate for removal.
>>>>
>>>> - Doug
>>>>
>>>>
>>>
>>>> _______________________________________________
>>>> swift-evolution mailing list swift-evolution at swift.org
>>>> https://lists.swift.org/mailman/listinfo/swift-evolution
>>>
>>> _______________________________________________
>>> swift-evolution mailing list swift-evolution at swift.org
>>> https://lists.swift.org/mailman/listinfo/swift-evolution
>>
>> _______________________________________________
>> swift-evolution mailing list swift-evolution at swift.org
>> https://lists.swift.org/mailman/listinfo/swift-evolution
>
> _________________________________________________
> swift-evolution mailing list swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151203/f2110093/attachment.html>


More information about the swift-evolution mailing list