<div dir="ltr">I absolutely agree with John, and I think, we should push this through evolution process.<div><br></div><div>That old voting wasn&#39;t public, or &quot;official&quot;.</div><div>I insist that we decide this via a formal review. Even if it means that the proposal will be explicitly rejected.</div><div><br></div><div>- Anton</div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-05-02 22:07 GMT+03:00 John McCall <span dir="ltr">&lt;<a href="mailto:rjmccall@apple.com" target="_blank">rjmccall@apple.com</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">&gt; On May 2, 2016, at 11:47 AM, Chris Lattner &lt;<a href="mailto:clattner@apple.com">clattner@apple.com</a>&gt; wrote:<br>
&gt; On May 2, 2016, at 11:12 AM, John McCall via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt;&gt; On May 2, 2016, at 9:39 AM, Jordan Rose via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br>
&gt;&gt;&gt;&gt; On May 1, 2016, at 13:09, Brent Royal-Gordon via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; Pattern binding for optionals will look like:<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; if let x? = y { ... }<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; I suggested precisely this in February. The core team shot it down:<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; We tried this* and got a lot of negative feedback. Optionals are unwrapped too often for people to be comfortable writing &quot;if let name? = optionalCondition&quot;.<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; <a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160201/008964.html" rel="noreferrer" target="_blank">https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160201/008964.html</a><br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Having said that, this still seems like a good idea to me, but they&#39;re the ones with implementation experience; all I have is an elegant idea.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Yeah, as nice as it sounds, it didn’t work out in practice. I’ll add it to the frequently-suggested list.<br>
&gt;&gt;<br>
&gt;&gt; Yeah.  My take on it is that &#39;if let&#39; was probably a mistake, but once we made it, it was really hard to back out.<br>
&gt;<br>
&gt; I understand that you (and probably a ton of other people on this list) feel that way, but I disagree pretty strongly.  I think we have the right design here.<br>
&gt;<br>
&gt; Context: As was mentioned up-thread, in the Swift 2 development cycle, we significantly extended pattern matching (this is when we added ‘if case’, etc).  One of the things we implemented - but then backed out - was exactly the proposal above. We did this because we found it to be the *wrong* thing to do.<br>
&gt;<br>
&gt; The reason is simple: most developers don’t grok pattern matching.  Particularly for people new to swift, “if let” is taught as a magic for dealing with optionals (which it is). This is a very useful mechanic when working in Swift, and this way of thinking is fine.  Optionals are very prominent, and having special sugar for dealing with them is important, even as people grow to become swift experts in time.<br>
&gt;<br>
&gt; Going with the proposal would definitely simplify the language (&#39;if case’ could probably go away), but would force everyone, all the time, to think about pattern matching.  This would be a barrier to entry that many programmers should never have to face.  The fact that many people don’t think about things in terms of pattern matching is the root cause for the comments about “it seems weird that the question mark is on the LHS of the assignment”.<br>
&gt;<br>
&gt; Finally, some may argue that making pattern matching more prominent would help teach pattern matching and get more people to use it.  That may be true, but our goal here is to build a pragmatic language that helps people get things done, not push to one specific language feature.  I personally love pattern matching (and was the one who drove and implemented the Swift 2 pattern matching enhancements), but it is an esoteric and special case feature.  It makes sense for it to be “buried” under “if case”: those who are unfamiliar with the syntax have something they can google for.<br>
<br>
</span>I understand what you&#39;re saying here, but I don&#39;t think your conclusions follow.  You wouldn&#39;t teach &quot;if let x? = whatever&quot; as an aspect of a generic pattern-matching feature just because &quot;x?&quot; happens to be a pattern.  You would still introduce it as magic for dealing with optionals, and the syntax would nicely reinforce a general impression that &quot;? is how I deal with optionals&quot;.  Instead, it feels more magical because nothing about the syntax suggests optionals; it&#39;s just something you have to know.<br>
<br>
Meanwhile the &quot;if let&quot; syntax has proven to compose poorly, and in particular it makes compound conditions unnecessarily limited/awkward because you can&#39;t bind a non-optional value and then test something about it without doing something like &quot;if let x = Optional(whatever) where x.isBeautiful&quot;.<br>
<br>
Anyway, like I said, I don&#39;t think it&#39;s something we can change.<br>
<span class="HOEnZb"><font color="#888888"><br>
John.</font></span></blockquote></div><br></div>