What is your evaluation of the proposal?
-1.
The problem this solves has not been a significant or noticeable problem in my own experience with Swift.
To double-check my intuition on this, I did a quick check of our Swift codebase at work, to see how many places there are where this language change would be useful.
To estimate the size of our codebase, I executed this command in the shell:
find . -name '*swift' | xargs wc -l
It turns out we have about 110,000 lines of Swift code (including comments and external libraries).
To determine how many obvious places there are where we could benefit from this syntax sugar, I went to Xcode and did Find / Regular Expression on our Workspace, and entered the following regular expression:
if[:space:]*let[:space:]*\w+[:space:]*=[:space:]*.*[:space:]*\{[:space:]*for
The search returned only one result. This regular expression is imperfect, since it will not match if let
forms that bind multiple variables on separate lines. Maybe that will produce more hits?
This one is more inclusive but will also produce false positives:
if[:space:]*let[:space:]*\w+[:space:]*=[:space:]*(?s:.)*[:space:]*\{[:space:]*for
Inspecting the 8 hits from this one, I still found only one instance, the original one, where this new language syntax would be helpful.
I am a bit surprised by this low number but it is consistent with my personal experience: I've never felt this to be a problem.
Maybe I messed up the regular expression? If so, I'd love to re-try the search if someone can suggest a better one, or a show how to do a smart, syntactically-aware search.
Is the problem being addressed significant enough to warrant a change to Swift?
No.
In fact, I worry this solution is worse than the problem. It introduces a subtle syntactic change, making the language more complex and less explicit, in order to remove what has been (in my experience) a small and infrequent piece of boilerplate.
Does this proposal fit well with the feel and direction of Swift?
No. As Matt Gallagher pointed out, the closest precedents are the as?
and try?
keywords, both of which introduce an optional, rather than affecting the interpretation of an optional.
If you have used other languages or libraries with a similar feature, how do you feel that this proposal compares to those?
N/A.
How much effort did you put into your review? A glance, a quick reading, or an in-depth study?
I read this entire thread, and searched the largest Swift codebase I know personally in order to estimate how often this language change would be useful.