<div dir="ltr"><div class="gmail_extra">The rendered version differs from the text appended to your message. I&#39;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,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;">Enum Case &quot;Overloading&quot;</h3><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,blinkmacsystemfont,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;;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-highlight gmail-highlight-source-swift" style="box-sizing:border-box;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,blinkmacsystemfont,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;;font-size:16px"><pre style="box-sizing:border-box;font-family:sfmono-regular,consolas,&#39;liberation mono&#39;,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-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">enum</span> <span class="gmail-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">Expr</span> {
    <span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> <span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">literal</span>(<span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Bool</span>)
    <span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> <span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">literal</span>(<span class="gmail-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,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;;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-highlight gmail-highlight-source-swift" style="box-sizing:border-box;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,blinkmacsystemfont,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;;font-size:16px"><pre style="box-sizing:border-box;font-family:sfmono-regular,consolas,&#39;liberation mono&#39;,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-pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"><span class="gmail-pl-c" style="box-sizing:border-box">//</span> It&#39;s clear which case is being constructed in the following.</span>
<span class="gmail-pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"></span><span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> aBool<span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">:</span> Expr <span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">=</span> .<span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">literal</span>(<span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">false</span>)
<span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> anInt<span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">:</span> Expr <span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">=</span> .<span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">literal</span>(<span class="gmail-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,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;;font-size:16px">User must specify an <code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&#39;liberation mono&#39;,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-highlight gmail-highlight-source-swift" style="box-sizing:border-box;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,blinkmacsystemfont,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;;font-size:16px"><pre style="box-sizing:border-box;font-family:sfmono-regular,consolas,&#39;liberation mono&#39;,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-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> .<span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">literal</span>(<span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> value) <span class="gmail-pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"><span class="gmail-pl-c" style="box-sizing:border-box">//</span> this is ambiguous</span>
<span class="gmail-pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"></span><span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> .<span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">literal</span>(<span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> value <span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">as</span> <span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Bool</span>) <span class="gmail-pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"><span class="gmail-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&#39;t you proposing to allow `case .literal(let value: Bool)`? For one, it would seem to be more consistent. Second, since we still have some use cases where there&#39;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`. 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><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,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;"><a id="gmail-user-content-alternative-payload-less-case-declaration" class="gmail-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"></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,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;;font-size:16px">In Swift 3, the following syntax is valid:</p><div class="gmail-highlight gmail-highlight-source-swift" style="box-sizing:border-box;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,blinkmacsystemfont,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;;font-size:16px"><pre style="box-sizing:border-box;font-family:sfmono-regular,consolas,&#39;liberation mono&#39;,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-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">enum</span> <span class="gmail-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">Tree</span> {
    <span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> <span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">leaf</span>() <span class="gmail-pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"><span class="gmail-pl-c" style="box-sizing:border-box">//</span> the type of this constructor is confusing!</span>
<span class="gmail-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,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;;font-size:16px"><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&#39;liberation mono&#39;,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,&#39;liberation mono&#39;,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 style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,blinkmacsystemfont,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;;font-size:16px">We propose this syntax declare the &quot;bare&quot; case instead. So it&#39;s going to be the equivalent of</p><div class="gmail-highlight gmail-highlight-source-swift" style="box-sizing:border-box;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,blinkmacsystemfont,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;;font-size:16px"><pre style="box-sizing:border-box;font-family:sfmono-regular,consolas,&#39;liberation mono&#39;,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-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">enum</span> <span class="gmail-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">Tree</span> {
    <span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> <span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">leaf</span> <span class="gmail-pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"><span class="gmail-pl-c" style="box-sizing:border-box">//</span> `()` is optional and does the same thing.</span>
<span class="gmail-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,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;"><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,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;"><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(())`. 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 `() -&gt; Tree` instead of the current `(()) -&gt; Tree`?</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,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;"><span 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></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,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;"><a id="gmail-user-content-pattern-consistency" class="gmail-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"></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,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;;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-highlight gmail-highlight-source-swift" style="box-sizing:border-box;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,blinkmacsystemfont,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;;font-size:16px"><pre style="box-sizing:border-box;font-family:sfmono-regular,consolas,&#39;liberation mono&#39;,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-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">indirect</span> <span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">enum</span> <span class="gmail-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">Expr</span> {
    <span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> <span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">variable</span>(<span class="gmail-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)"><span class="gmail-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">name</span></span>: <span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">String</span>)
    <span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> <span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">lambda</span>(<span class="gmail-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)"><span class="gmail-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">parameters</span></span>: [<span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">String</span>], <span class="gmail-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)"><span class="gmail-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,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;;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,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;;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-highlight gmail-highlight-source-swift" style="box-sizing:border-box;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,blinkmacsystemfont,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;;font-size:16px"><pre style="box-sizing:border-box;font-family:sfmono-regular,consolas,&#39;liberation mono&#39;,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-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> .<span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">variable</span>(<span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">name</span>: <span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> x) <span class="gmail-pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"><span class="gmail-pl-c" style="box-sizing:border-box">//</span> okay</span>
<span class="gmail-pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"></span><span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> .<span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">variable</span>(<span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">x</span>: <span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> x) <span class="gmail-pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"><span class="gmail-pl-c" style="box-sizing:border-box">//</span> compile error; there&#39;s no label `x`</span>
<span class="gmail-pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"></span><span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> .<span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">lambda</span>(<span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">parameters</span>: <span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> params, <span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">body</span>: <span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> body) <span class="gmail-pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"><span class="gmail-pl-c" style="box-sizing:border-box">//</span> Okay</span>
<span class="gmail-pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"></span><span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> .<span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">lambda</span>(<span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">params</span>: <span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> params, <span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">body</span>: <span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> body) <span class="gmail-pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"><span class="gmail-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,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;;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-highlight gmail-highlight-source-swift" style="box-sizing:border-box;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,blinkmacsystemfont,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;;font-size:16px"><pre style="box-sizing:border-box;font-family:sfmono-regular,consolas,&#39;liberation mono&#39;,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-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> .<span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">variable</span>(<span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> name) <span class="gmail-pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"><span class="gmail-pl-c" style="box-sizing:border-box">//</span> okay, because the name is the same as the label</span>
<span class="gmail-pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"></span><span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> .<span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">lambda</span>(<span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> parameters, <span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> body) <span class="gmail-pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"><span class="gmail-pl-c" style="box-sizing:border-box">//</span> this is okay too, same reason.</span>
<span class="gmail-pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"></span><span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> .<span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">variable</span>(<span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> x) <span class="gmail-pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"><span class="gmail-pl-c" style="box-sizing:border-box">//</span> compiler error. label must appear one way or another.</span>
<span class="gmail-pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"></span><span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> .<span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">lambda</span>(<span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> params, <span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> body) <span class="gmail-pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"><span class="gmail-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,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;"><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&#39;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><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. 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&#39;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><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,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;;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-highlight gmail-highlight-source-swift" style="box-sizing:border-box;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,blinkmacsystemfont,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;;font-size:16px"><pre style="box-sizing:border-box;font-family:sfmono-regular,consolas,&#39;liberation mono&#39;,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-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> .<span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">lambda</span>(<span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">parameters</span>: <span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> params, <span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> body) <span class="gmail-pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"><span class="gmail-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,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;;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-highlight gmail-highlight-source-swift" style="box-sizing:border-box;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,blinkmacsystemfont,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;;font-size:16px"><pre style="box-sizing:border-box;font-family:sfmono-regular,consolas,&#39;liberation mono&#39;,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-pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"><span class="gmail-pl-c" style="box-sizing:border-box">//</span> deprecated: matching all associated values as a tuple</span>
<span class="gmail-pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"></span><span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">if</span> <span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> <span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> .<span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">lambda</span>(f) <span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">=</span> anLambdaExpr {
    <span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">evaluateLambda</span>(<span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">parameters</span>: f.<span class="gmail-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">parameters</span>, <span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">body</span>: f.<span class="gmail-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,&#39;segoe ui&#39;,helvetica,arial,sans-serif,&#39;apple color emoji&#39;,&#39;segoe ui emoji&#39;,&#39;segoe ui symbol&#39;"><a id="gmail-user-content-source-compatibility" class="gmail-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"></a></h2></div></div>