<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 Mar 9, 2017, at 11:48 AM, Daniel Duan &lt;<a href="mailto:daniel@duan.org" class="">daniel@duan.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" class=""><div class=""><br class="Apple-interchange-newline">On Mar 9, 2017, at 12:31 AM, Xiaodi Wu &lt;<a href="mailto:xiaodi.wu@gmail.com" class="">xiaodi.wu@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">On Thu, Mar 9, 2017 at 1:07 AM, Daniel Duan<span class="Apple-converted-space">&nbsp;</span><span dir="ltr" class="">&lt;<a href="mailto:daniel@duan.org" target="_blank" class="">daniel@duan.org</a>&gt;</span><span class="Apple-converted-space">&nbsp;</span>wrote:<br class=""><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div dir="auto" class=""><div class="">Thanks for the thoughtful feed Xiaodi! Replies are inline. I'm going to incorporate some of the responses into the proposal.</div><span class="gmail-"><div id="gmail-m_-8040313148962180841AppleMailSignature" class=""><br class=""></div><div class="">On Mar 8, 2017, at 9:56 PM, Xiaodi Wu &lt;<a href="mailto:xiaodi.wu@gmail.com" target="_blank" class="">xiaodi.wu@gmail.com</a>&gt; wrote:<br class=""><br class=""></div><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra">The rendered version differs from the text appended to your message. I'll assume the more fully fleshed out version is what you intend to submit. Three comments/questions:</div><div class="gmail_extra"><br class=""></div><div class="gmail_extra"><h3 class="" style="box-sizing: border-box; margin-top: 24px; margin-bottom: 16px; font-size: 1.25em; line-height: 1.25; color: rgb(36, 41, 46); font-family: -apple-system, blinkmacsystemfont, 'segoe ui', helvetica, arial, sans-serif, 'apple color emoji', 'segoe ui emoji', 'segoe ui symbol';">Enum Case "Overloading"</h3><p class="" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, blinkmacsystemfont, 'segoe ui', helvetica, arial, sans-serif, 'apple color emoji', 'segoe ui emoji', 'segoe ui symbol'; font-size: 16px;">An enum may contain cases with the same full name but with associated values of different types. For example:</p><div class="gmail-m_-8040313148962180841gmail-highlight gmail-m_-8040313148962180841gmail-highlight-source-swift" style="box-sizing: border-box; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, blinkmacsystemfont, 'segoe ui', helvetica, arial, sans-serif, 'apple color emoji', 'segoe ui emoji', 'segoe ui symbol'; font-size: 16px;"><pre class="" style="box-sizing: border-box; font-family: sfmono-regular, consolas, 'liberation mono', menlo, courier, monospace; font-size: 13.600000381469727px; margin-top: 0px; margin-bottom: 0px; line-height: 1.45; word-wrap: normal; padding: 16px; overflow: auto; background-color: rgb(246, 248, 250); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-break: normal;"><span class="gmail-m_-8040313148962180841gmail-pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">enum</span> <span class="gmail-m_-8040313148962180841gmail-pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">Expr</span> {
    <span class="gmail-m_-8040313148962180841gmail-pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">case</span> <span class="gmail-m_-8040313148962180841gmail-pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">literal</span>(<span class="gmail-m_-8040313148962180841gmail-pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">Bool</span>)
    <span class="gmail-m_-8040313148962180841gmail-pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">case</span> <span class="gmail-m_-8040313148962180841gmail-pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">literal</span>(<span class="gmail-m_-8040313148962180841gmail-pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">Int</span>)
}</pre></div><p class="" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, blinkmacsystemfont, 'segoe ui', helvetica, arial, sans-serif, 'apple color emoji', 'segoe ui emoji', 'segoe ui symbol'; font-size: 16px;">The above cases have overloaded constructors, which follow the same rules as functions at call site for disambiguation:</p><div class="gmail-m_-8040313148962180841gmail-highlight gmail-m_-8040313148962180841gmail-highlight-source-swift" style="box-sizing: border-box; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, blinkmacsystemfont, 'segoe ui', helvetica, arial, sans-serif, 'apple color emoji', 'segoe ui emoji', 'segoe ui symbol'; font-size: 16px;"><pre class="" style="box-sizing: border-box; font-family: sfmono-regular, consolas, 'liberation mono', menlo, courier, monospace; font-size: 13.600000381469727px; margin-top: 0px; margin-bottom: 0px; line-height: 1.45; word-wrap: normal; padding: 16px; overflow: auto; background-color: rgb(246, 248, 250); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-break: normal;"><span class="gmail-m_-8040313148962180841gmail-pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"><span class="gmail-m_-8040313148962180841gmail-pl-c" style="box-sizing: border-box;">//</span> It's clear which case is being constructed in the following.</span>
<span class="gmail-m_-8040313148962180841gmail-pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"></span><span class="gmail-m_-8040313148962180841gmail-pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">let</span> aBool<span class="gmail-m_-8040313148962180841gmail-pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">:</span> Expr <span class="gmail-m_-8040313148962180841gmail-pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> .<span class="gmail-m_-8040313148962180841gmail-pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">literal</span>(<span class="gmail-m_-8040313148962180841gmail-pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">false</span>)
<span class="gmail-m_-8040313148962180841gmail-pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">let</span> anInt<span class="gmail-m_-8040313148962180841gmail-pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">:</span> Expr <span class="gmail-m_-8040313148962180841gmail-pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> .<span class="gmail-m_-8040313148962180841gmail-pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">literal</span>(<span class="gmail-m_-8040313148962180841gmail-pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">42</span>)</pre></div><p class="" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, blinkmacsystemfont, 'segoe ui', helvetica, arial, sans-serif, 'apple color emoji', 'segoe ui emoji', 'segoe ui symbol'; font-size: 16px;">User must specify an&nbsp;<code class="" style="box-sizing: border-box; font-family: sfmono-regular, consolas, 'liberation mono', menlo, courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">as</code>&nbsp;expression in sub-patterns in pattern matching, in order to match with such cases:</p><div class="gmail-m_-8040313148962180841gmail-highlight gmail-m_-8040313148962180841gmail-highlight-source-swift" style="box-sizing: border-box; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, blinkmacsystemfont, 'segoe ui', helvetica, arial, sans-serif, 'apple color emoji', 'segoe ui emoji', 'segoe ui symbol'; font-size: 16px;"><pre class="" style="box-sizing: border-box; font-family: sfmono-regular, consolas, 'liberation mono', menlo, courier, monospace; font-size: 13.600000381469727px; margin-top: 0px; margin-bottom: 0px; line-height: 1.45; word-wrap: normal; padding: 16px; overflow: auto; background-color: rgb(246, 248, 250); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-break: normal;"><span class="gmail-m_-8040313148962180841gmail-pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">case</span> .<span class="gmail-m_-8040313148962180841gmail-pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">literal</span>(<span class="gmail-m_-8040313148962180841gmail-pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">let</span> value) <span class="gmail-m_-8040313148962180841gmail-pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"><span class="gmail-m_-8040313148962180841gmail-pl-c" style="box-sizing: border-box;">//</span> this is ambiguous</span>
<span class="gmail-m_-8040313148962180841gmail-pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"></span><span class="gmail-m_-8040313148962180841gmail-pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">case</span> .<span class="gmail-m_-8040313148962180841gmail-pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">literal</span>(<span class="gmail-m_-8040313148962180841gmail-pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">let</span> value <span class="gmail-m_-8040313148962180841gmail-pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">as</span> <span class="gmail-m_-8040313148962180841gmail-pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">Bool</span>) <span class="gmail-m_-8040313148962180841gmail-pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"><span class="gmail-m_-8040313148962180841gmail-pl-c" style="box-sizing: border-box;">//</span> matches `case literal(Bool)`</span></pre></div><div class="gmail_extra"><br class=""></div>Comment/question 1: Here, why aren't you proposing to allow `case .literal(let value: Bool)`? For one, it would seem to be more consistent.</div></div></div></blockquote><div class=""><br class=""></div></span><div class="">The example in proposal doesn't include any labels. Are you suggesting two colons for sub-patterns with labels? Like `case .literal(value: let value: Bool)`?&nbsp; This looks jarring. But I'm definitely open to other suggestions.</div></div></blockquote><div class=""><br class=""></div><div class="">That does look jarring. But hmm.</div><div class="">&nbsp;</div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div dir="auto" class=""><span class="gmail-"><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra">Second, since we still have some use cases where there's Obj-C bridging magic with `as`, using `as` in this way may run into ambiguity issues if (for example) you have two cases, one with associated value of type `String` and the other of type `NSString`.</div></div></div></blockquote><div class=""><br class=""></div></span><div class="">Either this should be rejected at declaration, or we need a way to accept a "pre-magic" resolution at pattern matching, when this scenarios is at hand.</div></div></blockquote><div class=""><br class=""></div><div class="">Or we align pattern matching to function syntax and have such cases disambiguated in that way (see below).</div><div class="">&nbsp;</div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div dir="auto" class=""><div class="">I'm on the phone so I can't verify. Wouldn't function overloading face a similar problem?</div><span class="gmail-"><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra">Also, since enum cases are to be like functions, I assume that the more verbose `as` version would work for free: `case .literal(let value) as (Bool) -&gt; Expr`?</div><div class="gmail_extra"><br class=""></div></div></div></blockquote><div class=""><br class=""></div></span>This is not being proposed. When a user sees/authors a case, their expectation for the declared case constructor should resemble that of a function. Pattern matching was considered separately since it's not relatable syntactically.</div></blockquote><div class=""><br class=""></div><div class="">This requires justification. If enum cases are to be like functions, then the logical expectation is that pattern matching should work in that way too. I see no rationale to undergird your claim that pattern matching is "not relatable syntactically." Allowing `case .literal(let value) as (Bool) -&gt; Expr` would solve the issue above, as well as provide more flexibility with the issues below.</div></div></div></div></div></blockquote><div class=""><br class=""></div>I have concerns about the verbosity this syntax introduces. Example:</div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><div class="">enum A { case v(Int) }</div><div class="">enum B { case v(A); case v(Int) }</div></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">To disambiguate a value of type B, it would be</div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><div class="">case .v(A.v(let xValue)) as ((Int -&gt; A) -&gt; B)</div><div class=""><br class=""></div><div class="">This scales poorly for cases with deeper recursions and/or more associated values.</div><div class=""><br class=""></div><div class="">Disambiguate at the sub-pattern level doesn’t have this scalability problem.</div></div></div></blockquote><div><br class=""></div>This also is not the right meaning of `as`. `as` coerces the subpattern type, and a `.v(...)` pattern has type B. This coercion makes no sense.</div><div><br class=""></div><div>Personally I think that overloading is unnecessary scope creep and should be left out of the proposal.</div><div><br class=""><blockquote type="cite" class=""><div class=""><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><div class="">—</div><div class=""><br class=""></div><div class="">We’ve encountered a bigger question that it initial seems. Let’s zoom out.</div><div class=""><br class=""></div><div class="">There are 2 popular kinds of patterns for value deconstruction in PLs: patterns for trees and sequences. The former deconstructs value who’s prominently recursive: enum, struct, tuple; the latter deals with list-like (grows in 1 direction indefinitely) things. We are now investigating the syntax that can potentially be used for all tree patterns. Whereas the “shape” alone isn’t enough information, user must use the type to supplement the pattern for a successful match. If we introduce patterns for structs in the future, whatever we came up here for type disambiguation should work there.</div><blockquote type="cite" class=""><div class=""><div dir="ltr" class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div dir="auto" class=""><span class="gmail-"><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><h3 class="" style="box-sizing: border-box; margin-top: 24px; margin-bottom: 16px; font-size: 1.25em; line-height: 1.25; color: rgb(36, 41, 46); font-family: -apple-system, blinkmacsystemfont, 'segoe ui', helvetica, arial, sans-serif, 'apple color emoji', 'segoe ui emoji', 'segoe ui symbol';"><a id="gmail-m_-8040313148962180841gmail-user-content-alternative-payload-less-case-declaration" class="gmail-m_-8040313148962180841gmail-anchor" href="https://github.com/dduan/swift-evolution/blob/SE0155-rev2/proposals/0155-normalize-enum-case-representation.md#alternative-payload-less-case-declaration" target="_blank" style="box-sizing: border-box; background-color: transparent; color: rgb(3, 102, 214); text-decoration: none; float: left; padding-right: 4px; line-height: 1;"></a>Alternative Payload-less Case Declaration</h3><p class="" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, blinkmacsystemfont, 'segoe ui', helvetica, arial, sans-serif, 'apple color emoji', 'segoe ui emoji', 'segoe ui symbol'; font-size: 16px;">In Swift 3, the following syntax is valid:</p><div class="gmail-m_-8040313148962180841gmail-highlight gmail-m_-8040313148962180841gmail-highlight-source-swift" style="box-sizing: border-box; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, blinkmacsystemfont, 'segoe ui', helvetica, arial, sans-serif, 'apple color emoji', 'segoe ui emoji', 'segoe ui symbol'; font-size: 16px;"><pre class="" style="box-sizing: border-box; font-family: sfmono-regular, consolas, 'liberation mono', menlo, courier, monospace; font-size: 13.600000381469727px; margin-top: 0px; margin-bottom: 0px; line-height: 1.45; word-wrap: normal; padding: 16px; overflow: auto; background-color: rgb(246, 248, 250); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-break: normal;"><span class="gmail-m_-8040313148962180841gmail-pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">enum</span> <span class="gmail-m_-8040313148962180841gmail-pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">Tree</span> {
    <span class="gmail-m_-8040313148962180841gmail-pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">case</span> <span class="gmail-m_-8040313148962180841gmail-pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">leaf</span>() <span class="gmail-m_-8040313148962180841gmail-pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"><span class="gmail-m_-8040313148962180841gmail-pl-c" style="box-sizing: border-box;">//</span> the type of this constructor is confusing!</span>
<span class="gmail-m_-8040313148962180841gmail-pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"></span>}</pre></div><p class="" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, blinkmacsystemfont, 'segoe ui', helvetica, arial, sans-serif, 'apple color emoji', 'segoe ui emoji', 'segoe ui symbol'; font-size: 16px;"><code class="" style="box-sizing: border-box; font-family: sfmono-regular, consolas, 'liberation mono', menlo, courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">Tree.leaf</code>&nbsp;has a very unexpected type to most Swift users:&nbsp;<code class="" style="box-sizing: border-box; font-family: sfmono-regular, consolas, 'liberation mono', menlo, courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">(()) -&gt; Tree</code></p><p class="" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, blinkmacsystemfont, 'segoe ui', helvetica, arial, sans-serif, 'apple color emoji', 'segoe ui emoji', 'segoe ui symbol'; font-size: 16px;">We propose this syntax declare the "bare" case instead. So it's going to be the equivalent of</p><div class="gmail-m_-8040313148962180841gmail-highlight gmail-m_-8040313148962180841gmail-highlight-source-swift" style="box-sizing: border-box; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, blinkmacsystemfont, 'segoe ui', helvetica, arial, sans-serif, 'apple color emoji', 'segoe ui emoji', 'segoe ui symbol'; font-size: 16px;"><pre class="" style="box-sizing: border-box; font-family: sfmono-regular, consolas, 'liberation mono', menlo, courier, monospace; font-size: 13.600000381469727px; margin-top: 0px; margin-bottom: 0px; line-height: 1.45; word-wrap: normal; padding: 16px; overflow: auto; background-color: rgb(246, 248, 250); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-break: normal;"><span class="gmail-m_-8040313148962180841gmail-pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">enum</span> <span class="gmail-m_-8040313148962180841gmail-pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">Tree</span> {
    <span class="gmail-m_-8040313148962180841gmail-pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">case</span> <span class="gmail-m_-8040313148962180841gmail-pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">leaf</span> <span class="gmail-m_-8040313148962180841gmail-pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"><span class="gmail-m_-8040313148962180841gmail-pl-c" style="box-sizing: border-box;">//</span> `()` is optional and does the same thing.</span>
<span class="gmail-m_-8040313148962180841gmail-pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"></span>}</pre></div><h3 class="" style="box-sizing: border-box; margin-top: 24px; margin-bottom: 16px; font-size: 1.25em; line-height: 1.25; color: rgb(36, 41, 46); font-family: -apple-system, blinkmacsystemfont, 'segoe ui', helvetica, arial, sans-serif, 'apple color emoji', 'segoe ui emoji', 'segoe ui symbol';"><span class="" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: small; font-weight: normal;"><br class=""></span></h3><h3 class="" style="box-sizing: border-box; margin-top: 24px; margin-bottom: 16px; font-size: 1.25em; line-height: 1.25; color: rgb(36, 41, 46); font-family: -apple-system, blinkmacsystemfont, 'segoe ui', helvetica, arial, sans-serif, 'apple color emoji', 'segoe ui emoji', 'segoe ui symbol';"><span class="" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: small; font-weight: normal;">Comment/question 2: First, if associated values are not to be modeled as tuples, for backwards compatibility&nbsp;</span><span class="" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: small; font-weight: normal;">the rare uses of `case leaf()` should be migrated to `case leaf(())`.</span></h3></div></div></div></blockquote></span><div class="">Yes,</div></div></blockquote><div class=""><br class=""></div><div class="">Cool.</div><div class="">&nbsp;</div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div dir="auto" class=""><div class="">and when user uses a arbitrary name when they should have used a label, or when labels are misspelled, the compiler should suggest the correct labels.</div></div></blockquote><div class=""><br class=""></div><div class="">As below, I disagree with this restriction very strongly.</div><div class="">&nbsp;</div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div dir="auto" class=""><div class="">I wasn't sure how much of migrator related thing should go into a proposal. Perhaps there should be more.</div><span class="gmail-"><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><h3 class="" style="box-sizing: border-box; margin-top: 24px; margin-bottom: 16px; font-size: 1.25em; line-height: 1.25; color: rgb(36, 41, 46); font-family: -apple-system, blinkmacsystemfont, 'segoe ui', helvetica, arial, sans-serif, 'apple color emoji', 'segoe ui emoji', 'segoe ui symbol';"><span class="" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: small; font-weight: normal;">Second,&nbsp;</span><span class="" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: small; font-weight: normal;">to be clear, you are _not_ proposing additional sugar so that a case without an associated value be equivalent to a case that has an associated value of type `Void`, correct? You are saying that, with your proposal, both `case leaf()` and `case leaf` would be regarded as being of type `() -&gt; Tree` instead of the current `(()) -&gt; Tree`?</span></h3></div></div></div></blockquote></span><div class="">Correct. I'm _not_ proposing implicit `Void`.</div><span class="gmail-"><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><h3 class="" style="box-sizing: border-box; margin-top: 24px; margin-bottom: 16px; font-size: 1.25em; line-height: 1.25; color: rgb(36, 41, 46); font-family: -apple-system, blinkmacsystemfont, 'segoe ui', helvetica, arial, sans-serif, 'apple color emoji', 'segoe ui emoji', 'segoe ui symbol';"><span class="" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: small; font-weight: normal;">[The latter (i.e. `() -&gt; Tree`) seems entirely fine. The former (i.e. additional sugar for `(()) -&gt; Tree`) seems mostly fine, except that it would introduce an inconsistency with raw values that IMO is awkward. That is, if I have `enum Foo { case bar }`, it would make case `bar` have implied associated type `Void`; but, if I have `enum Foo: Int { case bar }`, would case `bar` have raw value `0` of type `Int` as well as associated value `()` of type `Void`?]</span><br class=""></h3><div class=""><span class="" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: small; font-weight: normal;"><br class=""></span></div><h3 class="" style="box-sizing: border-box; margin-top: 24px; margin-bottom: 16px; font-size: 1.25em; line-height: 1.25; color: rgb(36, 41, 46); font-family: -apple-system, blinkmacsystemfont, 'segoe ui', helvetica, arial, sans-serif, 'apple color emoji', 'segoe ui emoji', 'segoe ui symbol';"><a id="gmail-m_-8040313148962180841gmail-user-content-pattern-consistency" class="gmail-m_-8040313148962180841gmail-anchor" href="https://github.com/dduan/swift-evolution/blob/SE0155-rev2/proposals/0155-normalize-enum-case-representation.md#pattern-consistency" target="_blank" style="box-sizing: border-box; background-color: transparent; color: rgb(3, 102, 214); text-decoration: none; float: left; padding-right: 4px; line-height: 1;"></a>Pattern Consistency</h3><p class="" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, blinkmacsystemfont, 'segoe ui', helvetica, arial, sans-serif, 'apple color emoji', 'segoe ui emoji', 'segoe ui symbol'; font-size: 16px;"><em class="" style="box-sizing: border-box;">(The following enum will be used throughout code snippets in this section).</em></p><div class="gmail-m_-8040313148962180841gmail-highlight gmail-m_-8040313148962180841gmail-highlight-source-swift" style="box-sizing: border-box; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, blinkmacsystemfont, 'segoe ui', helvetica, arial, sans-serif, 'apple color emoji', 'segoe ui emoji', 'segoe ui symbol'; font-size: 16px;"><pre class="" style="box-sizing: border-box; font-family: sfmono-regular, consolas, 'liberation mono', menlo, courier, monospace; font-size: 13.600000381469727px; margin-top: 0px; margin-bottom: 0px; line-height: 1.45; word-wrap: normal; padding: 16px; overflow: auto; background-color: rgb(246, 248, 250); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-break: normal;"><span class="gmail-m_-8040313148962180841gmail-pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">indirect</span> <span class="gmail-m_-8040313148962180841gmail-pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">enum</span> <span class="gmail-m_-8040313148962180841gmail-pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">Expr</span> {
    <span class="gmail-m_-8040313148962180841gmail-pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">case</span> <span class="gmail-m_-8040313148962180841gmail-pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">variable</span>(<span class="gmail-m_-8040313148962180841gmail-pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);"><span class="gmail-m_-8040313148962180841gmail-pl-smi" style="box-sizing: border-box; color: rgb(51, 51, 51);">name</span></span>: <span class="gmail-m_-8040313148962180841gmail-pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">String</span>)
    <span class="gmail-m_-8040313148962180841gmail-pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">case</span> <span class="gmail-m_-8040313148962180841gmail-pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">lambda</span>(<span class="gmail-m_-8040313148962180841gmail-pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);"><span class="gmail-m_-8040313148962180841gmail-pl-smi" style="box-sizing: border-box; color: rgb(51, 51, 51);">parameters</span></span>: [<span class="gmail-m_-8040313148962180841gmail-pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">String</span>], <span class="gmail-m_-8040313148962180841gmail-pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);"><span class="gmail-m_-8040313148962180841gmail-pl-smi" style="box-sizing: border-box; color: rgb(51, 51, 51);">body</span></span>: Expr)
}</pre></div><p class="" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, blinkmacsystemfont, 'segoe ui', helvetica, arial, sans-serif, 'apple color emoji', 'segoe ui emoji', 'segoe ui symbol'; font-size: 16px;">Compared to patterns in Swift 3, matching against enum cases will follow stricter rules. This is a consequence of no longer relying on tuple patterns.</p><p class="" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, blinkmacsystemfont, 'segoe ui', helvetica, arial, sans-serif, 'apple color emoji', 'segoe ui emoji', 'segoe ui symbol'; font-size: 16px;">When an associated value has a label, the sub-pattern must include the label exactly as declared. There are two variants that should look familiar to Swift 3 users. Variant 1 allows user to bind the associated value to arbitrary name in the pattern by requiring the label:</p><div class="gmail-m_-8040313148962180841gmail-highlight gmail-m_-8040313148962180841gmail-highlight-source-swift" style="box-sizing: border-box; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, blinkmacsystemfont, 'segoe ui', helvetica, arial, sans-serif, 'apple color emoji', 'segoe ui emoji', 'segoe ui symbol'; font-size: 16px;"><pre class="" style="box-sizing: border-box; font-family: sfmono-regular, consolas, 'liberation mono', menlo, courier, monospace; font-size: 13.600000381469727px; margin-top: 0px; margin-bottom: 0px; line-height: 1.45; word-wrap: normal; padding: 16px; overflow: auto; background-color: rgb(246, 248, 250); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-break: normal;"><span class="gmail-m_-8040313148962180841gmail-pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">case</span> .<span class="gmail-m_-8040313148962180841gmail-pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">variable</span>(<span class="gmail-m_-8040313148962180841gmail-pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">name</span>: <span class="gmail-m_-8040313148962180841gmail-pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">let</span> x) <span class="gmail-m_-8040313148962180841gmail-pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"><span class="gmail-m_-8040313148962180841gmail-pl-c" style="box-sizing: border-box;">//</span> okay</span>
<span class="gmail-m_-8040313148962180841gmail-pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"></span><span class="gmail-m_-8040313148962180841gmail-pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">case</span> .<span class="gmail-m_-8040313148962180841gmail-pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">variable</span>(<span class="gmail-m_-8040313148962180841gmail-pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">x</span>: <span class="gmail-m_-8040313148962180841gmail-pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">let</span> x) <span class="gmail-m_-8040313148962180841gmail-pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"><span class="gmail-m_-8040313148962180841gmail-pl-c" style="box-sizing: border-box;">//</span> compile error; there's no label `x`</span>
<span class="gmail-m_-8040313148962180841gmail-pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"></span><span class="gmail-m_-8040313148962180841gmail-pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">case</span> .<span class="gmail-m_-8040313148962180841gmail-pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">lambda</span>(<span class="gmail-m_-8040313148962180841gmail-pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">parameters</span>: <span class="gmail-m_-8040313148962180841gmail-pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">let</span> params, <span class="gmail-m_-8040313148962180841gmail-pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">body</span>: <span class="gmail-m_-8040313148962180841gmail-pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">let</span> body) <span class="gmail-m_-8040313148962180841gmail-pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"><span class="gmail-m_-8040313148962180841gmail-pl-c" style="box-sizing: border-box;">//</span> Okay</span>
<span class="gmail-m_-8040313148962180841gmail-pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"></span><span class="gmail-m_-8040313148962180841gmail-pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">case</span> .<span class="gmail-m_-8040313148962180841gmail-pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">lambda</span>(<span class="gmail-m_-8040313148962180841gmail-pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">params</span>: <span class="gmail-m_-8040313148962180841gmail-pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">let</span> params, <span class="gmail-m_-8040313148962180841gmail-pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">body</span>: <span class="gmail-m_-8040313148962180841gmail-pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">let</span> body) <span class="gmail-m_-8040313148962180841gmail-pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"><span class="gmail-m_-8040313148962180841gmail-pl-c" style="box-sizing: border-box;">//</span> error: 1st label mismatches</span></pre></div><p class="" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, blinkmacsystemfont, 'segoe ui', helvetica, arial, sans-serif, 'apple color emoji', 'segoe ui emoji', 'segoe ui symbol'; font-size: 16px;">User may choose not to use binding names that differ from labels. In this variant, the corresponding value will bind to the label, resulting in this shorter form:</p><div class="gmail-m_-8040313148962180841gmail-highlight gmail-m_-8040313148962180841gmail-highlight-source-swift" style="box-sizing: border-box; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, blinkmacsystemfont, 'segoe ui', helvetica, arial, sans-serif, 'apple color emoji', 'segoe ui emoji', 'segoe ui symbol'; font-size: 16px;"><pre class="" style="box-sizing: border-box; font-family: sfmono-regular, consolas, 'liberation mono', menlo, courier, monospace; font-size: 13.600000381469727px; margin-top: 0px; margin-bottom: 0px; line-height: 1.45; word-wrap: normal; padding: 16px; overflow: auto; background-color: rgb(246, 248, 250); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-break: normal;"><span class="gmail-m_-8040313148962180841gmail-pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">case</span> .<span class="gmail-m_-8040313148962180841gmail-pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">variable</span>(<span class="gmail-m_-8040313148962180841gmail-pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">let</span> name) <span class="gmail-m_-8040313148962180841gmail-pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"><span class="gmail-m_-8040313148962180841gmail-pl-c" style="box-sizing: border-box;">//</span> okay, because the name is the same as the label</span>
<span class="gmail-m_-8040313148962180841gmail-pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"></span><span class="gmail-m_-8040313148962180841gmail-pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">case</span> .<span class="gmail-m_-8040313148962180841gmail-pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">lambda</span>(<span class="gmail-m_-8040313148962180841gmail-pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">let</span> parameters, <span class="gmail-m_-8040313148962180841gmail-pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">let</span> body) <span class="gmail-m_-8040313148962180841gmail-pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"><span class="gmail-m_-8040313148962180841gmail-pl-c" style="box-sizing: border-box;">//</span> this is okay too, same reason.</span>
<span class="gmail-m_-8040313148962180841gmail-pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"></span><span class="gmail-m_-8040313148962180841gmail-pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">case</span> .<span class="gmail-m_-8040313148962180841gmail-pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">variable</span>(<span class="gmail-m_-8040313148962180841gmail-pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">let</span> x) <span class="gmail-m_-8040313148962180841gmail-pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"><span class="gmail-m_-8040313148962180841gmail-pl-c" style="box-sizing: border-box;">//</span> compiler error. label must appear one way or another.</span>
<span class="gmail-m_-8040313148962180841gmail-pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"></span><span class="gmail-m_-8040313148962180841gmail-pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">case</span> .<span class="gmail-m_-8040313148962180841gmail-pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">lambda</span>(<span class="gmail-m_-8040313148962180841gmail-pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">let</span> params, <span class="gmail-m_-8040313148962180841gmail-pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">let</span> body) <span class="gmail-m_-8040313148962180841gmail-pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"><span class="gmail-m_-8040313148962180841gmail-pl-c" style="box-sizing: border-box;">//</span> compiler error, same reason as above.</span></pre></div><h3 class="" style="box-sizing: border-box; margin-top: 24px; margin-bottom: 16px; font-size: 1.25em; line-height: 1.25; color: rgb(36, 41, 46); font-family: -apple-system, blinkmacsystemfont, 'segoe ui', helvetica, arial, sans-serif, 'apple color emoji', 'segoe ui emoji', 'segoe ui symbol';"><span class="" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: small; font-weight: normal;">Comment/question 3:&nbsp;</span><span class="" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: small; font-weight: normal;">Being a source-breaking change, that requires extreme justification, and I just don't think there is one for this rule.&nbsp;</span><span class="" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: small; font-weight: normal;">The perceived problem being addressed (that one might try to bind `parameters` to `body` and `body` to `parameters`) is unchanged whether enum cases are modeled as tuples or functions, so aligning enum cases to functions is not in and of itself justification to revisit the issue of whether to try to prohibit this.&nbsp;</span></h3></div></div></div></blockquote></span><div class="">To reiterate, here patterns are changed not for any kind of "alignment" with function syntax. It changed because we dropped the tuple pattern (which remains available for matching with tuple values, btw), therefore we need to consider what a first-class syntax for enum case would look like.</div></div></blockquote><div class=""><br class=""></div><div class="">Since the rationale for this proposal is to "normalize" enum cases by making them more function-like, again you will need to justify why pattern matching should break from that overarching goal.</div><div class=""><br class=""></div><div class="">This is a source-breaking change, so it's not enough that a "first-class syntax" from the ground up would be different from the status quo (which was the Swift 3 evolution standard--if we were to do it again from scratch, would we still do it this way?). The Swift 4 evolution expectation is that a source-breaking change should require "extreme" justification.</div></div></div></div></div></blockquote><br class=""><div class="">Fair enough. I think the Swift 3 criteria is met. As for Swift 4, I used the word “deprecated” in the source compatibility section. I imagine this means that only deprecation warnings and fix-its are issued in Swift 4 and the warning becomes an error in Swift 5. Obviously, that’s not a justification…</div><div class=""><br class=""></div><div class="">What do you think Joe?&nbsp;</div></div></div></blockquote><div><br class=""></div><div>Unifying the declaration model is worth a minor source break, IMO.</div><br class=""><blockquote type="cite" class=""><div class=""><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div class="gmail_extra"><div class="gmail_quote"><div class=""><br class=""></div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div dir="auto" class=""><div class="">The justification for this breaking change is this: with tuples, labels in pattern is not well enforced. User can skip them, bind value to totally arbitrary names, etc. I personally think emulating such rule prevents us from making pattern matching easier to read for experienced devs and easier to learn for new comers.&nbsp;</div></div></blockquote><div class=""><br class=""></div><div class="">Perhaps, but this is an argument that tuple pattern binding is inferior. It has nothing to do with enum cases in particular. In fact, several threads have touched on this topic holistically. The conclusions there have been that allowing (a: Int, b: Int) to bind (Int, Int) or vice versa is healthy and useful, but allowing (a: Int, b: Int) to bind (b: Int, c: Int) is not so good, and (a: Int, b: Int) binding (b: Int, a: Int) is counterintuitive and should be removed.</div></div></div></div></div></blockquote><div class=""><br class=""></div>Fantastic! Really appreciate this summary.<br class=""></div></div></blockquote><div><br class=""></div><div>Tuples are at the type system level convertible from labeled and unlabeled and in label-changing ways. We should arguably clamp down on that, and that might affect how pattern matching works with them. It isn't necessarily analogous to enum cases, since with enum cases we're working with a named declaration where the labels are needed for name lookup.</div><div><br class=""></div><div>-Joe</div></div></body></html>