[swift-evolution] Proposal: Optional Binding Shorthand Syntax
Chris Lattner
clattner at apple.com
Sun Dec 6 16:42:37 CST 2015
> On Dec 6, 2015, at 1:38 PM, Tyler Mandry via swift-evolution <swift-evolution at swift.org> wrote:
>
> What isn't clear to me from Chris's or John's comments is why the `if let x? = foo` syntax was taken away. Was it for backward-compatibility?
FWIW, that syntax hasn’t been taken away, it just means something different now.
if let x = foo() {
captures is privileged syntax for testing an optional and binding to the thing inside of it. The patch I linked to moved away from this, but at great cost: it uglified lots of common code. Swift privileges optional in a number of ways (e.g. it is the result of as?, try?, etc) and the standard library uses it pervasively as well. Optimizing for that common case makes sense.
-Chris
More information about the swift-evolution
mailing list