<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 May 5, 2017, at 8:34 AM, Vladimir.S &lt;<a href="mailto:svabox@gmail.com" class="">svabox@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">On 05.05.2017 6:12, Jose Cheyo Jimenez via swift-evolution wrote:<br class=""><blockquote type="cite" class="">I can't think of a single time when I would need a tuple shuffle but I don't really work with tuples much. It would be great to hear other people's usage of this feature.<br class="">I did not know that types could be overloaded with values. That was very surprising to me. Honestly I think that is the issue here. Not sure what can be done about it.<br class=""></blockquote><br class=""><blockquote type="cite" class="">let Int = 5 // works<br class="">let Void = "what?" // works.<br class=""></blockquote><br class="">Very interesting. Could some one clarify, why this is allowed? Isn't this is a bug we want to fix? At least by requiring a tilda like `Int`<br class="">And of course, you can't "overload" user defined type:<br class="">struct S {}<br class="">let S = 10 // Error: invalid redeclaration of ’S'<br class=""></div></div></blockquote><div><br class=""></div><div>What version of swift are you using? Could it be a regression?</div><div><br class=""></div><div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">Welcome to Apple Swift version 3.1 (swiftlang-802.0.51 clang-802.0.41). Type :help for assistance.</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #a9a9a9" class="">&nbsp; 1&gt; </span><span style="font-variant-ligatures: no-common-ligatures" class="">struct S {}</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #a9a9a9" class="">&nbsp; 2&gt; </span><span style="font-variant-ligatures: no-common-ligatures" class="">let S = 10</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(51, 187, 200); background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">S: Int = 10</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #a9a9a9" class="">&nbsp; 3&gt; </span><span style="font-variant-ligatures: no-common-ligatures" class="">print(S)</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">error: repl.swift:3:7: error: ambiguous use of 'S'</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">print(S)</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; &nbsp; ^</span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div></div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div class=""><br class=""><blockquote type="cite" class="">On May 4, 2017, at 7:14 PM, Robert Widmann via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a> &lt;<a href="mailto:swift-evolution@swift.org" class="">mailto:swift-evolution@swift.org</a>&gt;&gt; wrote:<br class=""><blockquote type="cite" class="">Hi all,<br class=""><br class="">So sorry that this proposal comes so late in the game, but I feel it’s too important not to bring it to the attention of the community now. &nbsp;Attached is a proposal to deprecate a language feature many of you will probably have never had the chance to use: Tuple Shuffles. &nbsp;I’ve attached a copy of the first draft of the proposal below, but the latest copy can be read on Github &lt;<a href="https://github.com/apple/swift-evolution/pull/705/files" class="">https://github.com/apple/swift-evolution/pull/705/files</a>&gt;.<br class=""><br class="">Thanks!<br class=""><br class="">~Robert Widmann<br class=""><br class=""><br class=""> &nbsp;Deprecate Tuple Shuffles<br class=""><br class=""> &nbsp;* Proposal: SE-NNNN<br class=""> &nbsp;&nbsp;&nbsp;&lt;<a href="https://github.com/CodaFi/swift-evolution/blob/8eaf320b3c2a117909fc0269c398e89c033a4b9f/proposals/NNNN-filename.md" class="">https://github.com/CodaFi/swift-evolution/blob/8eaf320b3c2a117909fc0269c398e89c033a4b9f/proposals/NNNN-filename.md</a>&gt;<br class=""> &nbsp;* Authors: Robert Widmann &lt;<a href="https://github.com/codafi" class="">https://github.com/codafi</a>&gt;<br class=""> &nbsp;* Review Manager: TBD<br class=""> &nbsp;* Status: Awaiting review<br class=""><br class=""><br class=""> &nbsp;&nbsp;&nbsp;&lt;<a href="https://github.com/CodaFi/swift-evolution/blob/8eaf320b3c2a117909fc0269c398e89c033a4b9f/proposals/NNNN-deprecate-tuple-shuffles.md#introduction" class="">https://github.com/CodaFi/swift-evolution/blob/8eaf320b3c2a117909fc0269c398e89c033a4b9f/proposals/NNNN-deprecate-tuple-shuffles.md#introduction</a>&gt;Introduction<br class=""><br class="">This proposal seeks the deprecation of a little-known feature of Swift called a "Tuple Shuffle".<br class=""><br class=""><br class=""> &nbsp;&nbsp;&nbsp;&lt;<a href="https://github.com/CodaFi/swift-evolution/blob/8eaf320b3c2a117909fc0269c398e89c033a4b9f/proposals/NNNN-deprecate-tuple-shuffles.md#motivation" class="">https://github.com/CodaFi/swift-evolution/blob/8eaf320b3c2a117909fc0269c398e89c033a4b9f/proposals/NNNN-deprecate-tuple-shuffles.md#motivation</a>&gt;Motivation<br class=""><br class="">A tuple-shuffle is an undocumented feature of Swift in which one can re-order the indices of a tuple by writing a pattern that describes a permutation in a syntax reminiscent of adding type-annotations to a parameter list:<br class=""><br class="">let &nbsp;a= &nbsp;(x:1,y:2)<br class="">var &nbsp;b: &nbsp;(y:Int,x:Int)<br class="">b= &nbsp;a<br class=""><br class="">It can be used to simultaneously destructure and reorder a tuple:<br class=""><br class="">let &nbsp;tuple= &nbsp;(first:0,second: (x:1,y:2))<br class="">let &nbsp;(second: (x: b,y: c),first: a)= &nbsp;tuple<br class=""><br class="">It can also be used to map parameter labels out of order in a call expression:<br class=""><br class="">func &nbsp;foo(_ &nbsp;: (x :Int, y :Int)) {}<br class="">foo((y:5,x:10))// Valid<br class=""><br class="">Note that a tuple shuffle is distinct from a re-assignment through a tuple pattern. For example, this series of statements will continue to function as before:<br class=""><br class="">var &nbsp;x= &nbsp;5<br class="">var &nbsp;y= &nbsp;10<br class="">var &nbsp;z= &nbsp;15<br class="">(z, y, x)= &nbsp;(x, z, y)<br class=""><br class="">Their inclusion in the language complicates every part of the compiler stack, uses a syntax that can be confused for type annotations &lt;<a href="https://twitter.com/CodaFi_/status/860246169854894081" class="">https://twitter.com/CodaFi_/status/860246169854894081</a>&gt;, contradicts the goals of earlier SE's (see SE-0060 &lt;<a href="https://github.com/apple/swift-evolution/blob/9cf2685293108ea3efcbebb7ee6a8618b83d4a90/proposals/0060-defaulted-parameter-order.md" class="">https://github.com/apple/swift-evolution/blob/9cf2685293108ea3efcbebb7ee6a8618b83d4a90/proposals/0060-defaulted-parameter-order.md</a>&gt;), and makes non-sensical patterns possible in surprising places.<br class=""><br class="">Take switch-statements, for example:<br class=""><br class="">switch &nbsp;((0,0),0){<br class="">case &nbsp;(_ &nbsp;:let &nbsp;(y, z),_ &nbsp;:let &nbsp;s): &nbsp;()// We are forbidden from giving these patterns names other than "_"<br class="">default: &nbsp;()<br class="">}<br class=""><br class="">This proposal seeks to deprecate them in Swift 3 compatibility mode and enforce that deprecation as a hard error in Swift 4 to facilitate their eventual removal from the language.<br class=""><br class=""><br class=""> &nbsp;&nbsp;&nbsp;&lt;<a href="https://github.com/CodaFi/swift-evolution/blob/8eaf320b3c2a117909fc0269c398e89c033a4b9f/proposals/NNNN-deprecate-tuple-shuffles.md#proposed-solution" class="">https://github.com/CodaFi/swift-evolution/blob/8eaf320b3c2a117909fc0269c398e89c033a4b9f/proposals/NNNN-deprecate-tuple-shuffles.md#proposed-solution</a>&gt;Proposed<br class=""> &nbsp;&nbsp;&nbsp;solution<br class=""><br class="">Construction of Tuple Shuffle Expressions will become a warning in Swift 3 compatibility mode and will be a hard-error in Swift 4.<br class=""><br class=""><br class=""> &nbsp;&nbsp;&nbsp;&lt;<a href="https://github.com/CodaFi/swift-evolution/blob/8eaf320b3c2a117909fc0269c398e89c033a4b9f/proposals/NNNN-deprecate-tuple-shuffles.md#detailed-design" class="">https://github.com/CodaFi/swift-evolution/blob/8eaf320b3c2a117909fc0269c398e89c033a4b9f/proposals/NNNN-deprecate-tuple-shuffles.md#detailed-design</a>&gt;Detailed<br class=""> &nbsp;&nbsp;&nbsp;design<br class=""><br class="">In addition to the necessary diagnostics, the grammar will be ammended to simplify the following productions:<br class=""><br class="">tuple-pattern → (tuple-pattern-element-list &lt;opt&gt;)<br class="">tuple-pattern-element-list → tuple-pattern-element | tuple-pattern-element , tuple-pattern-element-list<br class="">- tuple-pattern-element → pattern | identifier:pattern<br class="">+ tuple-pattern-element → pattern<br class=""><br class=""><br class=""> &nbsp;&nbsp;&nbsp;&lt;<a href="https://github.com/CodaFi/swift-evolution/blob/8eaf320b3c2a117909fc0269c398e89c033a4b9f/proposals/NNNN-deprecate-tuple-shuffles.md#impact-on-existing-code" class="">https://github.com/CodaFi/swift-evolution/blob/8eaf320b3c2a117909fc0269c398e89c033a4b9f/proposals/NNNN-deprecate-tuple-shuffles.md#impact-on-existing-code</a>&gt;Impact<br class=""> &nbsp;&nbsp;&nbsp;on Existing Code<br class=""><br class="">Because very little code is intentionally using Tuple Shuffles, impact on existing code will be negligible but not non-zero.<br class=""><br class=""><br class=""> &nbsp;&nbsp;&nbsp;&lt;<a href="https://github.com/CodaFi/swift-evolution/blob/8eaf320b3c2a117909fc0269c398e89c033a4b9f/proposals/NNNN-deprecate-tuple-shuffles.md#alternatives-considered" class="">https://github.com/CodaFi/swift-evolution/blob/8eaf320b3c2a117909fc0269c398e89c033a4b9f/proposals/NNNN-deprecate-tuple-shuffles.md#alternatives-considered</a>&gt;Alternatives<br class=""> &nbsp;&nbsp;&nbsp;considered<br class=""><br class="">Continue to keep the architecture in place to facilitate this feature.<br class="">_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a> &lt;<a href="mailto:swift-evolution@swift.org" class="">mailto:swift-evolution@swift.org</a>&gt;<br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></blockquote>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></blockquote></div></div></blockquote></div><br class=""></body></html>