<div dir="ltr">+1<div>Ondrej</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jan 29, 2016 at 8:14 AM, Taras Zakharko via swift-evolution <span dir="ltr">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">A very reasonable decision! It is also good to know that accepted proposals are not “absolute” but will be reviewed again if  necessary. <div><br></div><div><div>— Taras</div><div><div class="h5"><div><div><br><div><blockquote type="cite"><div>On 29 Jan 2016, at 07:20, Paul Cantrell via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><br><div><div style="word-wrap:break-word"><div>+3 from me — one for each of the conclusions. This sounds exactly right.</div><div><br></div><div>If I understand correctly, we now alllmost have a nice language-wide uniformity:</div><div><br></div><div>• Anywhere the syntax allows “let” it also allows “var,” and vice versa.</div><div>• Where they’re allowed, exactly one of them _must_ appear.</div><div><br></div><div>The exception I can think of is for loops, where the iterator variable’s “let” is still implied. (Are there others?) It would be more uniform, I suppose, to require this:</div><div><br></div><div><span style="white-space:pre-wrap">        </span>for let i in 0..&lt;256</div><div><br></div><div>…but that just looks intolerably awkward to my eyes.</div><div><br></div><div>Cheers, P</div><div><br></div><br><div><blockquote type="cite"><div>On Jan 28, 2016, at 11:41 PM, Chris Lattner via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><br><div><div style="word-wrap:break-word">The core team met to discuss SE-0003, and we have a new conclusion, described below.  As was mentioned on the other thread, this proposal is a bit unusual because it predates Swift open source, and thus didn’t go through the full evolution process, nor did it get the normal public review that would come with it.<div><div><br></div><div><br></div></div><div>The core team broke this proposal down into a few different cases, each of which came to a different conclusion.  To be clear up front, this is not a clear-cut topic, and there are opinions on all sides.  Here are the decisions the core team came to, along with some rationale:</div><div><br></div><div><br></div><div><b>Parameter Lists</b></div><div><br></div><div>‘var’ in a parameter list is problematic for a number of reasons:</div><div><br></div><div>- Parameter lists currently allow both “inout” and “var”, and real confusion occurs for some people learning swift that expect “var” to provide reference semantics.</div><div><br></div><div>- Parameter lists are not “patterns” in the language, so neither “let” nor “var” really make sense there.  Parameters were patterns in a much older swift design, but that was eliminated a long time ago and this aspect never got reconsidered.</div><div><br></div><div>- “var” in a parameter list is odd because it is an implementation detail being foisted on the interface to the function.  To be fair, we already have this with &quot;API names&quot; vs &quot;internal names”, but this is a bigger semantic implementation detail.</div><div><br></div><div><br></div><div>Conclusion: The core team decided that we should REMOVE “var” and “let” from parameter lists.</div><div><br></div><div><div>“var” in a parameter list is convenient sugar that defines away some minor boilerplate (the shadowing copy), however, the cost benefit tradeoff doesn’t pay enough to keep it.</div></div><div><br></div><div><br></div><div><b>Patterns</b></div><div><br></div><div>&quot;if var”, “for var”, &quot;if case var&quot; etc all use the pattern grammar (aka &quot;pattern matching&quot; and “destructuring” features described in TSPL).  We discussed whether to eliminate var from this, with much more mixed results:</div><div><br></div><div>- We currently have a duality across the language between var and let which is common, unifying, and works really well in practice.  Eliminating var from pattern matching would make the language less uniform, because patterns wouldn’t align with var/let declarations.</div><div><br></div><div>- Working in Swift *demands* that you get an early grasp on what value semantics means, and “var x = y” is always a copy of the value.  As such, based on the strong duality mentioned above, it is reasonable to expect people to learn that “if var x = y” produces a copy and not a reference binding.</div><div><br></div><div>- There certainly is confusion from people who expect “if var” to do a reference binding, despite the comment directly above.  However, we feel that this is more of a point-in-time confusion than the parameter case, given that the parameter case exposes the ‘var’ as part of the function signature.</div><div><br></div><div><br></div><div><div>Conclusion: The core team decided that we should KEEP “var” and “let” in patterns.</div></div><div><br></div><div><br></div><div><b>Case Patterns</b></div><div><br></div><div>We had an additional discussion focused specifically on whether it would make sense to ban var in case patterns, e.g.:</div><div><span style="white-space:pre-wrap">        </span>case .Foo(var x):</div><div><br></div><div>- The core team agrees that this specific case is a common point of confusion, particularly because Swift doesn’t provide a way to get a mutable binding to the associated value in an enum.</div><div><br></div><div>- That said, making a special case for this would make Swift less regular.</div><div><br></div><div><br></div><div>Conclusions: </div><div>- The core team decided to KEEP “var” here.</div><div>- We will stop leading people into it by eliminating the &quot;note: change &#39;let&#39; to &#39;var&#39; to make it mutable” note that the compiler produces for patterns.</div><div><br></div><div>Eliminating the note allows users sufficiently knowledgable about Swift to keep using it, but people who just mash the “fixit” button to silence the compiler won’t get surprising behavior.</div><div><br></div><div>-Swift Core Team</div><div><br></div><div><br></div></div>_______________________________________________<br>swift-evolution mailing list<br><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br></div></blockquote></div><br></div>_______________________________________________<br>swift-evolution mailing list<br><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br></div></blockquote></div><br></div></div></div></div></div></div><br>_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
<br></blockquote></div><br></div>