<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 16 Jun 2017, at 00:41, David Hart &lt;<a href="mailto:david@hartbit.com" class="">david@hartbit.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On 15 Jun 2017, at 19:28, Chris Lattner &lt;<a href="mailto:sabre@nondot.org" class="">sabre@nondot.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="content-type" content="text/html; charset=utf-8" class=""><div dir="auto" class=""><div class=""><br class="">On Jun 15, 2017, at 9:41 AM, Xiaodi Wu via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; o</div><blockquote type="cite" class=""><div class=""><div class=""><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class=""><blockquote type="cite" class=""><div class=""><div class=""><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
&gt;<br class="">
&gt;&nbsp; &nbsp;let (a : Int, b : Float) = foo()<br class="">
<br class="">
<br class="">
I think it would be better if the compiler raised a warning whenever you tried to redefine a builtin type.</blockquote><div class=""><br class=""></div><div class="">That’s essentially my preferred solution as well, as it gets to the root of the confusion.</div><div class=""><br class=""></div><div class="">Naming a variable the same as a type should be similar to naming a variable the same as a reserved keyword and require backticks. (A previous suggestion to enforce capitalization falls down with full Unicode support and complicates interop where imported C structures might be lowercase and constants might be all caps.) No need to treat built-in types specially; it’s equally a problem with types imported from other libraries, which can be shadowed freely today. For full source compatibility this can be a warning instead of an error–should be sufficient as long as it’s brought to the user’s attention. In fact, probably most appropriate as a warning, since the _compiler_ knows exactly what’s going on, it’s the human that might be confused.</div></div></div></div></blockquote><div class=""><br class=""></div></div></div><div style="word-wrap:break-word" class=""><div class=""><div class="">I kind of agree with all you say. But I also feel that tuple element names in patterns are very rarely used and not worth the added complexity and confusing. Going back to the old: “Would be add it to Swift if it did not exist?”, I would say no.</div></div></div></blockquote><div class=""><br class=""></div><div class="">That was the standard for removing features before Swift 3, but with source compatibility the bar is now much higher.</div></div></div></div></blockquote><div class=""><br class=""></div><div class="">Completely agreed. &nbsp;My belief on this is that it is a legacy Swift 1 type system capability that no one uses. &nbsp;I have no data to show that though.</div><br class=""><blockquote type="cite" class=""><div class=""><div class=""><div class="gmail_quote"><div class=""> Is the feature harmful? </div></div></div></div></blockquote><div class=""><br class=""></div><div class="">Yes, absolutely. &nbsp;The shadowing isn't the thing that bothers me, it is that swift has a meaning for that very syntax in other contexts, and that this is completely different meaning. &nbsp;People absolutely would get confused by this if they encountered it in real code that they themselves didn't write, and I'm not aware of any good (non theoretical) use for it.</div><div class=""><br class=""></div><blockquote type="cite" class=""><div class=""><div class=""><div class="gmail_quote"><div class="">My point is, not on its own it isn’t: warning on variables shadowing types is sufficient to resolve the problems shown here.</div></div></div></div></blockquote><div class=""><br class=""></div>Again, my concern is that this is a confusing and misleading feature which complicates and potentially prevents composing other features in the future.<div class=""><div class=""><br class=""></div><div class=""><br class=""><blockquote type="cite" class=""><div class=""><div class=""><div class="gmail_quote"><div class=""><br class=""></div><div class="">How strange that we’re talking about this issue in a thread about SE-0110. </div></div></div></div></blockquote><div class=""><br class=""></div><div class=""><span style="background-color: rgba(255, 255, 255, 0);" class="">This came up in the discussion about 110 because we were exploring whether it was plausible to expand the function parameter grammar to support destructuring in the position where a name goes. &nbsp;There are many concerns about whether this is a good idea, but he existence of this in the tuple destructuring pattern grammar is pretty much a showstopper.</span></div><br class=""><blockquote type="cite" class=""><div class=""><div class=""><div class="gmail_quote"><div class="">If anything, the response to that proposal should be a cautionary tale that users can take poorly to removing features, sometimes in unanticipated ways.</div></div></div></div></blockquote><div class=""><br class=""></div><div class="">Agreed, it may be too late to correct this (certainly we can't outright remove it in Swift 4 if someone is using it for something important). &nbsp;However if it turns out that it really isn't used, then warning about it in 4 and removing it shortly after may be possible.</div></div></div></div></div></blockquote><div class=""><br class=""></div><div class="">And I think its difficult to make the parallel between the two. SE-0110 basically impacted everybody calling higher-order functions on Dictionary (+ more users from libraries like RxSwift), which makes an enormous proportion of the Swift community. On the other hand, despite the enormous amount of time I have sinked into learning, discussing and enjoying Swift, I never come upon the tuple element name syntax in patterns until Robert pointed to it out on twitter several weeks ago.</div></div></div></div></blockquote><div><br class=""></div><div>By the way, I’m not attempting to deduce that nobody uses this feature by the fact I didn’t know about it. But I think it’s one interesting datapoint when comparing it to SE-0110.</div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><blockquote type="cite" class=""><div class=""><div dir="auto" class=""><div class=""><div class="">-Chris</div><div class=""><br class=""><blockquote type="cite" class=""><div class=""><div class=""><div class="gmail_quote"><div class=""><br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class=""><div class=""></div></div></div></blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class=""><blockquote type="cite" class=""><div class=""><div class=""><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> `let (a : Int, b : Float) = foo()` is confusing but if you were to use your own type (e.g., `struct S {}` and replace Int and Float with S) you would get a compiler error. If the compiler warned you that you were reassigning Int and Float, you’d probably avoid that problem. Or, for a more extreme fix, we could make reassigning builtin types illegal since there is pretty much no valid reason to do that.<br class="">
<br class="">
<br class="">
&gt; On Jun 15, 2017, at 8:10 AM, Matthew Johnson via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt; wrote:<br class="">
&gt;<br class="">
&gt;<br class="">
&gt;<br class="">
&gt; Sent from my iPad<br class="">
&gt;<br class="">
&gt;&gt; On Jun 14, 2017, at 11:01 PM, Chris Lattner via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt; wrote:<br class="">
&gt;&gt;<br class="">
&gt;&gt;<br class="">
&gt;&gt;&gt; On Jun 12, 2017, at 10:07 PM, Paul Cantrell &lt;<a href="mailto:cantrell@pobox.com" target="_blank" class="">cantrell@pobox.com</a>&gt; wrote:<br class="">
&gt;&gt;&gt;<br class="">
&gt;&gt;&gt; What’s the status of this Chris’s double parens idea below? It garnered some positive responses, but the discussion seems to have fizzled out. Is there something needed to help nudge this along?<br class="">
&gt;&gt;&gt;<br class="">
&gt;&gt;&gt; What’s the likelihood of getting this fixed before Swift 4 goes live, and the great wave of readability regressions hits?<br class="">
&gt;&gt;<br class="">
&gt;&gt; We discussed this in the core team meeting today.&nbsp; Consensus seems to be that a change needs to be made to regain syntactic convenience here.&nbsp; Discussion was leaning towards allowing (at least) the parenthesized form, but more discussion is needed.<br class="">
&gt;&gt;<br class="">
&gt;&gt;<br class="">
&gt;&gt; One (tangential) thing that came up is that tuple element names in tuple *patterns* should probably be deprecated and removed at some point.&nbsp; Without looking, what variables does this declare?:<br class="">
&gt;&gt;<br class="">
&gt;&gt;&nbsp; &nbsp;let (a : Int, b : Float) = foo()<br class="">
&gt;<br class="">
&gt; Another option would be to require let to appear next to each name binding instead of allowing a single let for the whole pattern.&nbsp; I personally find that much more clear despite it being a little bit more verbose.<br class="">
&gt;<br class="">
&gt;&gt;<br class="">
&gt;&gt; ?<br class="">
&gt;&gt;<br class="">
&gt;&gt; -Chris<br class="">
&gt;&gt;<br class="">
&gt;&gt; _______________________________________________<br class="">
&gt;&gt; swift-evolution mailing list<br class="">
&gt;&gt; <a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a><br class="">
&gt;&gt; <a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="">
&gt;<br class="">
&gt; _______________________________________________<br class="">
&gt; swift-evolution mailing list<br class="">
&gt; <a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a><br class="">
&gt; <a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="">
<br class="">
_______________________________________________<br class="">
swift-evolution mailing list<br class="">
<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a><br class="">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="">
</blockquote></div></div>
_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div></blockquote></div></div></blockquote></div></div>
</div></blockquote><blockquote type="cite" class=""><div class=""><span class="">_______________________________________________</span><br class=""><span class="">swift-evolution mailing list</span><br class=""><span class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a></span><br class=""><span class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br class=""></div></blockquote></div></div></div></div></blockquote></div><br class=""></div></div></blockquote></div><br class=""></body></html>