[swift-evolution] C-style For Loops
Colin Barrett
colin at springsandstruts.com
Sun Dec 6 13:11:22 CST 2015
> On Dec 6, 2015, at 11:31 AM, David Waite via swift-evolution <swift-evolution at swift.org> wrote:
>
> Nearly every for loop I’ve written in other languages has used pre or post increment (depending on the language), which is being removed in Swift 3.0. It makes sense for 'for loops' to go if pre/post increment goes away.
I’m not 100% convinced by this line of reasoning (using the += form or successor() isn’t THAT clunky) but it is awfully poetic.
Fun fact, you write (albiet with different syntax) C-style for-loops as library code:
> for i in CStyle(0, {$0 < 20}, {$0 += 1}) {
> // do something 20 times
> }
Where CStyle is just a straightforward implementation of SequenceType. (Tuples allow for simultaneous iteration, which is usually when I end up with C-style for-loops)
(Apologies if this was mentioned up thread, I’ve only just recently joined the list)
-Colin
> -DW
>
>> On Dec 6, 2015, at 9:03 AM, Don Wills via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>>
>> I too hope that the proposal to remove C-style loops is rejected. Yes, they aren't that necessary any more, but if we want Swift to compete with Java, C#, C++ and C, there is no reason to remove basic features like C-style loops just because they are politically incorrect. If there was a functional reason, I might get on board with removing it, but there isn't.
>>
>> I also hope that the decision to remove increment and decrement operators is reversed using the same logic. Just because *you* don't like something that has been a feature of dozens of programming languages for 40 years doesn't mean removing that feature is a good idea. One man's goto statement is another man's Leatherman multi-tool. And FWIW, if C-style loops stay in the language, they become much more ugly without increment and decrement.
>>
>> Don Wills
>>
>>> On Dec 6, 2015, at 8:33 AM, inbox only via swift-evolution <swift-evolution at swift.org <mailto: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 <mailto: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 <mailto:swift-evolution at swift.org>
>>> https://lists.swift.org/mailman/listinfo/swift-evolution <https://lists.swift.org/mailman/listinfo/swift-evolution>
>>>
>>> _______________________________________________
>>> swift-evolution mailing list
>>> swift-evolution at swift.org <mailto:swift-evolution at swift.org>
>>> https://lists.swift.org/mailman/listinfo/swift-evolution <https://lists.swift.org/mailman/listinfo/swift-evolution>
>>
>> _______________________________________________
>> swift-evolution mailing list
>> swift-evolution at swift.org <mailto:swift-evolution at swift.org>
>> https://lists.swift.org/mailman/listinfo/swift-evolution <https://lists.swift.org/mailman/listinfo/swift-evolution>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org <mailto:swift-evolution at swift.org>
> https://lists.swift.org/mailman/listinfo/swift-evolution <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/b9e3b559/attachment.html>
More information about the swift-evolution
mailing list