[swift-evolution] Proposal: Optional Binding Shorthand Syntax
Chris Lattner
clattner at apple.com
Sat Dec 5 12:17:52 CST 2015
> On Dec 5, 2015, at 9:52 AM, Chris Lattner <clattner at apple.com> wrote:
>
>
>> 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.
Ah, here you go:
https://github.com/apple/swift/commit/20f8f09ea8de5eb1c0cb559e59c8a8e8a0e115a9#diff-4513b692cdd5476630ebb66b73d5bf4b
The behavior was later reverted to the Swift 1 behavior of privileging “if let” for optionals.
-Chris
More information about the swift-evolution
mailing list