[Swift] Get rid of the ... operator

Number:rdar://17307454 Date Originated:6/13/14
Status:Open Resolved:
Product:Developer Tools Product Version:
Classification: Reproducible:
While having language-level support for both closed ranges and half closed ranges sounds great on paper, the choice of ".." and "..." for those operators will cause nothing but trouble. These two operators have such similar behavior and such similar appearance that it is far too easy to mistake one for the other, both while writing code and while reading it. The potential for this error is so great, it even occurs in the text of The Swift Programming Language book, on pages 174-175. The example code reads:

for _ in 1...power {

while the accompanying text reads:

"It multiplies a starting value of 1 (that is, 3 to the power of 0) by 3, ten times, using a half-closed loop that starts with 0 and ends with 9."

The code and text are mismatched. If that mistake can be made in the documentation for the language, then you can bet it will be made by programmers using the language.

One option would be for Swift to adopt the mathematical symbols for ranges, [, (, ), and ]. This option poses a few problems (aside from potential difficulty parsing), not least of which many programmers will have long forgotten this part of their math training and still get confused.

Instead, I propose the language simply lose the closed range operator, which has limited use, and keep the half closed range operator, which is highly useful.

Steps to Reproduce

Expected Results

Actual Results


Xcode Version
Xcode 6 Beta 1

Additional Notes


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!