[swift-evolution] C-style For Loops
Liam Butler-Lawrence
liamdunn at me.com
Sun Dec 6 13:56:55 CST 2015
I’m going to add a +1 for Erica’s proposal. Here’s why:
1. For every situation in which the for loop could be used, a for…in (either with ranges or strides) or while loop could achieve the same goals.
2. For the vast majority of these cases, the for…in or while version is much cleaner and easier to read than for(init;test;inc). More extensive refactoring might be necessary in some cases, but in my opinion that effort would be worthwhile to improve readability and consistency.
3. For new programmers learning the language, the for…in is much easier to learn. To my understanding, this is a major goal of Swift. For those coming to Swift that have some experience with other languages, we should be guiding them towards the optimal Swift way of doing things. Letting those programmers use an inelegant, legacy feature “just because” does not seem to me to fit the goals of Swift. In addition, the for…in loop is not even a new Swift concept; many languages (including C++, and Objective-C, and Python) already have for..in style loops available.
4. To the comment that said "even that a feature isn't used doesn't mean that you need to remove that feature": I don’t agree. If a given feature is inferior to its alternatives and is not actually in common use, why not simplify the language and just remove it? I think many of us would agree that for(init;test;inc) loops fail the smell test we should be using: would we add this in Swift 3 if it didn’t already exist?
Lastly, I’d like to point out that I, too, had a knee-jerk negative reaction when I saw the already accepted proposal for removing ++ and --. After reading the rationale and discussion regarding that change, I completely changed my mind. I believe this proposal should accepted for similar reasons.
Thanks,
Liam
> On Dec 6, 2015, at 10:33 AM, inbox only via swift-evolution <swift-evolution at swift.org> wrote:
>
> True,even that a feature isn't used doesn't mean that you need to remove that feature.
> I hope that the proposal will be rejected.
>
> 2015-12-06 12:03 GMT+02:00 Clemens Wagner via swift-evolution <swift-evolution at swift.org>:
>> > We’ve developed a number of Swift apps for various clients over the past year and have not needed C style for loops either.
>>
>> But I think this is a very weak reason for *removing* any portion like C-loops and increment or decrement operators of a programming language. How about the developers and the productive code which used C-style loops already?
>>
>> I understand the reasons why you, Erica and the others don’t like C-style loops. But changing the philosophy of a productive programming language is a very bad idea.
>>
>> Cheers
>> Clemens
>> _______________________________________________
>> 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/20151206/0035dafb/attachment.html>
More information about the swift-evolution
mailing list