[swift-evolution] Proposal: Optional Binding Shorthand Syntax

Chris Lattner clattner at apple.com
Sat Dec 5 11:52:34 CST 2015


> On Dec 4, 2015, at 9:47 AM, John McCall <rjmccall at apple.com> wrote:
> 
> 
>> On Dec 3, 2015, at 11:07 PM, Kevin Ballard <kevin at sb.org> wrote:
>> 
>> If we change anything based on this, I’d suggest the simpler change of removing `if let`/`while let` and renaming `if case`/`while case` to `if let`/`while let`. Since Swift now has the ? pattern type to mean optional binding, it means that all existing instances of 
>> 
>>    if let foo = bar {
>> 
>> become the almost-identical
>> 
>>    if let foo? = bar {
> 
> This is something we carefully considered after introducing the ? pattern, and in fact it was even implemented for a time.  The lesson we took from that experience was that optional-binding is really, really important, and it really is worthwhile to recognize that importance by giving it special syntactic support.

+1 to what John said.  You can see this in the history, start with 20f8f09ea8de5eb1c0cb559e59c8a8e8a0e115a9.  Sorry, but I don’t know how to turn that hash into a github URL.

-Chris


More information about the swift-evolution mailing list