<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div><br><br>Sent from my iPad</div><div><br>On Mar 9, 2017, at 2:31 AM, Xiaodi Wu via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr">On Thu, Mar 9, 2017 at 1:07 AM, Daniel Duan <span dir="ltr"><<a href="mailto:daniel@duan.org" target="_blank">daniel@duan.org</a>></span> wrote:<br><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"><div>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"><br></div><div>On Mar 8, 2017, at 9:56 PM, Xiaodi Wu <<a href="mailto:xiaodi.wu@gmail.com" target="_blank">xiaodi.wu@gmail.com</a>> wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr"><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></div><div class="gmail_extra"><h3 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 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 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 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 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 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 <code 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> 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 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></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><br></div></span><div>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)`? This looks jarring. But I'm definitely open to other suggestions.</div></div></blockquote><div><br></div><div>That does look jarring. But hmm.</div><div> </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"><span class="gmail-"><blockquote type="cite"><div><div dir="ltr"><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><br></div></span><div>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><br></div><div>Or we align pattern matching to function syntax and have such cases disambiguated in that way (see below).</div><div> </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"><div> I'm on the phone so I can't verify. Wouldn't function overloading face a similar problem?</div><span class="gmail-"><br><blockquote type="cite"><div><div dir="ltr"><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) -> Expr`?</div><div class="gmail_extra"><br></div></div></div></blockquote><div><br></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><br></div><div>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) -> Expr` would solve the issue above, as well as provide more flexibility with the issues below.</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"><span class="gmail-"><blockquote type="cite"><div><div dir="ltr"><div class="gmail_extra"><h3 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" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration:none;float:left;padding-right:4px;line-height:1" target="_blank"></a>Alternative Payload-less Case Declaration</h3><p 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 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 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 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> has a very unexpected type to most Swift users: <code 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</code></p><p 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 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 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 style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-weight:normal"><br></span></h3><h3 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 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 </span><span 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>Yes,</div></div></blockquote><div><br></div><div>Cool.</div><div> </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"><div>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><br></div><div>As below, I disagree with this restriction very strongly.</div><div> </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"><div>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"><div><div dir="ltr"><div class="gmail_extra"><h3 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 style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-weight:normal">Second, </span><span 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 `() -> Tree` instead of the current `(()) -> Tree`?</span></h3></div></div></div></blockquote></span><div>Correct. I'm _not_ proposing implicit `Void`.</div><span class="gmail-"><blockquote type="cite"><div><div dir="ltr"><div class="gmail_extra"><h3 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 style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-weight:normal">[The latter (i.e. `() -> Tree`) seems entirely fine. The former (i.e. additional sugar for `(()) -> 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></h3><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-weight:normal"><br></span></div><h3 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" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration:none;float:left;padding-right:4px;line-height:1" target="_blank"></a>Pattern Consistency</h3><p 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 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 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 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 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 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 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 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 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 style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-weight:normal">Comment/question 3: </span><span 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. </span><span 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. </span></h3></div></div></div></blockquote></span><div>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><br></div><div>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></div></div></div></blockquote><div><br></div><div>I have argued repeatedly that enum cases play two distinct roles (and sometimes a third in the future). We need to embrace all of these roles. This proposal primarily normalizes the role of case-as-factory-method. </div><div><br></div><div>Pattern matching is a second role enum cases play. We already have syntax for patterns that match based on type. I see no reason we should introduce new matching syntax to disambiguate overloaded cases. The existing patterns work well for this purpose. Matching should be considered a role played by enum cases that is completely orthogonal to their role as a factory method.</div><div><br></div><div>The third role some cases will (hopefully) play in the future is as a subtype of the enum itself. All three roles are distinct and cases should align with other parts of the language when playing that role.</div><br><blockquote type="cite"><div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><br></div><div>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><br></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"><div>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. </div></div></blockquote><div><br></div><div>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><br></div><div>Emulating tuple rules is the backwards-compatible way. Therefore, it ought to be the default unless the source-breaking alternative is not merely easier but _overwhelmingly_ easier. If tuples are dangerously broken, then that calls for a proposal to change tuples.</div><div><br></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"><div>It's reasonable to expect existing patterns in the wild either already use the labels found in declaration or they are matching against label-less cases.</div></div></blockquote><div><br></div><div>I don't think that is reasonable to expect.</div></div></div></div></div></blockquote><div><br></div>I agree. I have code that will break. <div><br><blockquote type="cite"><div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div> </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"><div>In other words, existing code with good style won't be affected much.</div></div></blockquote><div><br></div><div>You're defining your preference as "good style" and saying that a proposal to enforce your preference by the compiler won't affect code with "good style" (i.e. adhering to your preference), which is tautologically true and also not a valid argument.</div></div></div></div></div></blockquote><div><br></div><div>I agree here as well. Labels in patterns can end up creating a lot of verbosity that makes code less clear. This is why I have argued for the internal / external name distinction and allowing the label to be elided by binding a name that matches the label or the "internal" name if it exists. This would likely break a lot less code as many existing bindings that omit labels probably qualify under this rule.</div><div><br></div><div>I don't consider this problematic enough to oppose the proposal. I like everything else about it and this topic could be revisited in the future.</div><br><blockquote type="cite"><div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div> </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"><div>For the code that actually would break, I think the migrator and the compiler can provide sufficient help in form of migration/fixits/warnings.</div><div><br></div><div>Ultimately I think requiring appearance of labels one way or another in patterns will improve both the readability of the pattern matching site as well as forcing the author of case declaration consider the use site more.</div><span class="gmail-"><blockquote type="cite"><div><div dir="ltr"><div class="gmail_extra"><h3 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 style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-weight:normal">In fact, I think the proposed solution suffers from two great weaknesses.</span><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-weight:normal"> First, it seems ad-hoc. Consider this: i</span><span style="font-family:arial,sans-serif;font-size:small;font-weight:normal;color:rgb(34,34,34)">f enum cases are to be modeled as functions, then I should be able to write something intermediate between the options above; namely: `case .variable(name:)(let x)`. Since `.variable` unambiguously refers to `.variable(name:)`, I should also be allowed to write `.variable(let x)` just as I am now.</span></h3></div></div></div></blockquote></span>Again, patterns are not to be modeled after functions. Only the declaration and usage of case constructors are.</div></blockquote><div><br></div><div>This requires justification. Why are they not to be? IMO, they ought to be.</div></div></div></div></div></blockquote><div><br></div><div>See above about the distinct roles enum cases play in the language. Why should we try to force the perspective of one of these roles (factory method) onto another (pattern matching)? That is what requires a lot of justification IMO.</div><br><blockquote type="cite"><div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><br></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"><span class="gmail-"><blockquote type="cite"><div><div dir="ltr"><div class="gmail_extra"><h3 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 style="font-family:arial,sans-serif;font-size:small;font-weight:normal;color:rgb(34,34,34)"> Second</span><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-weight:normal">, it </span><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-weight:normal">seems unduly restrictive. If, in the containing scope, I have a variable named `body` that I don't want to shadow, this rule would force me to either write the more verbose form or deal with shadowing `body`. </span><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-weight:normal">If a person opts for the shorter form, they are choosing not to use the label.</span></h3></div></div></div></blockquote></span><div>In fact this (to avoid label conflict in nesting) is the only reason the longer form allows rebinding to other names at all! You say "unduly restrictive", I say "necessarily flexible" :)</div></div></blockquote><div> </div><div>The great majority of Swift users don't read this list, nor care about the starting point from which a proposal added "flexibility." They compare Swift N to Swift N + 1, and in this case, there is a new restriction. That is the only comparison which matters. So make no mistake, you are proposing a source-breaking restriction. For the arguments I gave in my earlier reply, I believe it is _unduly_ restrictive.</div></div></div></div></div></blockquote><blockquote type="cite"><div><div dir="ltr"><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"><span class="gmail-"><blockquote type="cite"><div><div dir="ltr"><div class="gmail_extra"><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-weight:normal"><br></span></div><p 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">Only one of these variants may appear in a single pattern. Swift compiler will raise a compile error for mixed usage.</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 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)">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-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, can not mix the two.</span></pre></div><p 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">Some patterns will no longer match enum cases. For example, all associated values can bind as a tuple in Swift 3, this will no longer work after this proposal:</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 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> deprecated: matching all associated values as a tuple</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)">if</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-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> .<span class="gmail-m_-8040313148962180841gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">lambda</span>(f) <span class="gmail-m_-8040313148962180841gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">=</span> anLambdaExpr {
<span class="gmail-m_-8040313148962180841gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">evaluateLambda</span>(<span class="gmail-m_-8040313148962180841gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">parameters</span>: f.<span class="gmail-m_-8040313148962180841gmail-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">parameters</span>, <span class="gmail-m_-8040313148962180841gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">body</span>: f.<span class="gmail-m_-8040313148962180841gmail-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">body</span>)
}</pre><div><br></div></div><h2 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;line-height:1.25;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(234,236,239);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-source-compatibility" class="gmail-m_-8040313148962180841gmail-anchor" href="https://github.com/dduan/swift-evolution/blob/SE0155-rev2/proposals/0155-normalize-enum-case-representation.md#source-compatibility" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration:none;float:left;padding-right:4px;line-height:1" target="_blank"></a></h2></div></div>
</div></blockquote></span></div></blockquote></div><br></div></div>
</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>swift-evolution mailing list</span><br><span><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br></div></blockquote></div></body></html>