In the Swift language, allow use of and/or as well as &&/||
| Originator: | mauricerkelly | ||
| Number: | rdar://17651398 | Date Originated: | 12-Jul-2014 12:10 PM |
| Status: | Closed | Resolved: | |
| Product: | Developer Tools | Product Version: | |
| Classification: | Reproducible: | N/A |
Closed by Apple:
Engineering has determined that this issue behaves as intended based on the following:
This just encourages dialects of the language to spring up.
We are now closing this bug report.
If you have questions regarding the resolution of this issue, please update your bug report with that information.
Please be sure to regularly check new Apple releases for any updates that might affect this issue.
========
Original issue:
Swift has been designed as a modern programming language yet still retains many vestigial features of older languages. When performing logic operations, users are still forced to use logical operators like && and ||. I feel like it would help the readability of the language, and therefore increase it's appeal as a learning language, if Swift supported the use of "and" and "or" in addition to && and ||. I'm not proposing the removal of the original logical operators, just offering more modern versions as an addition.
Numerous languages support the interchangeable use of and/or and &&/|| - it would be nice to have this support in Swift as well.
Steps to Reproduce:
Steps to reproduce:
1. Open a new Swift playground in Xcode
2. Enter the following code into a Swift playground: if 1 == 1 and 2 == 2 or 3 == 3 { }
Expected Results:
3. The code should be parsed without error
Actual Results:
3. The parsed code indicates errors due to use of "and" and "or"
Comments
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!
I respect that, but personally, I think giving people a choice is overrated :)
(I like having multiple idiomatic ways of doing things — that adds expressiveness to the language — but with small syntactic choices like that, it's better, IMHO, to make one option and have everyone just deal with it.)
I personally find "and" and "or" more readable. In the past, the symbols may have helped the logical operators to stand out, but these days modern IDEs and syntax highlighting can help just as much IMO.
Either way, I didn't ask for them to be replaced, I asked for the option, so that people could choose.
"and" is prettier than "&&" and arguably easier to type, but the truth is, it's not really more readable. Our brains can mentally parse symbols faster than words. When words are used for just about everything — variable and function names, etc… — use of symbols for operators helps distinguish user-defined names from the language grammar.