<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="">I filled a bug report. <a href="https://bugs.swift.org/browse/SR-4811" class="">https://bugs.swift.org/browse/SR-4811</a><div class=""><br class=""></div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On May 5, 2017, at 9:38 AM, Jose Cheyo Jimenez <<a href="mailto:cheyo@masters3d.com" class="">cheyo@masters3d.com</a>> 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 May 5, 2017, at 8:34 AM, Vladimir.S <<a href="mailto:svabox@gmail.com" class="">svabox@gmail.com</a>> 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 class=""><br class=""></div><div class="">What version of swift are you using? Could it be a regression?</div><div class=""><br class=""></div><div class=""><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=""> 1> </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=""> 2> </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=""> 3> </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=""> ^</span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div></div><div class=""><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 <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a> <<a href="mailto:swift-evolution@swift.org" class="">mailto:swift-evolution@swift.org</a>>> 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. Attached is a proposal to deprecate a language feature many of you will probably have never had the chance to use: Tuple Shuffles. I’ve attached a copy of the first draft of the proposal below, but the latest copy can be read on Github <<a href="https://github.com/apple/swift-evolution/pull/705/files" class="">https://github.com/apple/swift-evolution/pull/705/files</a>>.<br class=""><br class="">Thanks!<br class=""><br class="">~Robert Widmann<br class=""><br class=""><br class=""> Deprecate Tuple Shuffles<br class=""><br class=""> * Proposal: SE-NNNN<br class=""> <<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>><br class=""> * Authors: Robert Widmann <<a href="https://github.com/codafi" class="">https://github.com/codafi</a>><br class=""> * Review Manager: TBD<br class=""> * Status: Awaiting review<br class=""><br class=""><br class=""> <<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>>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=""> <<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>>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 a= (x:1,y:2)<br class="">var b: (y:Int,x:Int)<br class="">b= a<br class=""><br class="">It can be used to simultaneously destructure and reorder a tuple:<br class=""><br class="">let tuple= (first:0,second: (x:1,y:2))<br class="">let (second: (x: b,y: c),first: a)= 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 foo(_ : (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 x= 5<br class="">var y= 10<br class="">var z= 15<br class="">(z, y, x)= (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 <<a href="https://twitter.com/CodaFi_/status/860246169854894081" class="">https://twitter.com/CodaFi_/status/860246169854894081</a>>, contradicts the goals of earlier SE's (see SE-0060 <<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>>), and makes non-sensical patterns possible in surprising places.<br class=""><br class="">Take switch-statements, for example:<br class=""><br class="">switch ((0,0),0){<br class="">case (_ :let (y, z),_ :let s): ()// We are forbidden from giving these patterns names other than "_"<br class="">default: ()<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=""> <<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>>Proposed<br class=""> 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=""> <<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>>Detailed<br class=""> 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 <opt>)<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=""> <<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>>Impact<br class=""> 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=""> <<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>>Alternatives<br class=""> 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> <<a href="mailto:swift-evolution@swift.org" class="">mailto:swift-evolution@swift.org</a>><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=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></blockquote></div></div></blockquote></div><br class=""></div></div></blockquote></div><br class=""></div></body></html>