<html><head><style>
body {
        font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
        padding:1em;
        margin:auto;
        background:#fefefe;
}

h1, h2, h3, h4, h5, h6 {
        font-weight: bold;
}

h1 {
        color: #000000;
        font-size: 28pt;
}

h2 {
        border-bottom: 1px solid #CCCCCC;
        color: #000000;
        font-size: 24px;
}

h3 {
        font-size: 18px;
}

h4 {
        font-size: 16px;
}

h5 {
        font-size: 14px;
}

h6 {
        color: #777777;
        background-color: inherit;
        font-size: 14px;
}

hr {
        height: 0.2em;
        border: 0;
        color: #CCCCCC;
        background-color: #CCCCCC;
    display: inherit;
}

p, blockquote, ul, ol, dl, li, table, pre {
        margin: 15px 0;
}

a, a:visited {
        color: #4183C4;
        background-color: inherit;
        text-decoration: none;
}

#message {
        border-radius: 6px;
        border: 1px solid #ccc;
        display:block;
        width:100%;
        height:60px;
        margin:6px 0px;
}

button, #ws {
        font-size: 12 pt;
        padding: 4px 6px;
        border-radius: 5px;
        border: 1px solid #bbb;
        background-color: #eee;
}

code, pre, #ws, #message {
        font-family: Monaco;
        font-size: 10pt;
        border-radius: 3px;
        background-color: #F8F8F8;
        color: inherit;
}

code {
        border: 1px solid #EAEAEA;
        margin: 0 2px;
        padding: 0 5px;
}

pre {
        border: 1px solid #CCCCCC;
        overflow: auto;
        padding: 4px 8px;
}

pre > code {
        border: 0;
        margin: 0;
        padding: 0;
}

#ws { background-color: #f8f8f8; }


.bloop_markdown table {
border-collapse: collapse;  
font-family: Helvetica, arial, freesans, clean, sans-serif;  
color: rgb(51, 51, 51);  
font-size: 15px; line-height: 25px;
padding: 0; }

.bloop_markdown table tr {
border-top: 1px solid #cccccc;
background-color: white;
margin: 0;
padding: 0; }
     
.bloop_markdown table tr:nth-child(2n) {
background-color: #f8f8f8; }

.bloop_markdown table tr th {
font-weight: bold;
border: 1px solid #cccccc;
margin: 0;
padding: 6px 13px; }

.bloop_markdown table tr td {
border: 1px solid #cccccc;
margin: 0;
padding: 6px 13px; }

.bloop_markdown table tr th :first-child, table tr td :first-child {
margin-top: 0; }

.bloop_markdown table tr th :last-child, table tr td :last-child {
margin-bottom: 0; }

.bloop_markdown blockquote{
  border-left: 4px solid #dddddd;
  padding: 0 15px;
  color: #777777; }
  blockquote > :first-child {
    margin-top: 0; }
  blockquote > :last-child {
    margin-bottom: 0; }

code, pre, #ws, #message {
    word-break: normal;
    word-wrap: normal;
}

hr {
    display: inherit;
}

.bloop_markdown :first-child {
    -webkit-margin-before: 0;
}

code, pre, #ws, #message {
    font-family: Menlo, Consolas, Liberation Mono, Courier, monospace;
}


.send { color:#77bb77; }
.server { color:#7799bb; }
.error { color:#AA0000; }</style></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class="bloop_markdown"><p>Great, thanks. Love it :) </p>

<p>+1 </p>

<p></p></div><div class="bloop_original_html"><style>body{font-family:Helvetica,Arial;font-size:13px}</style><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><br></div> <br> <div id="bloop_sign_1486042836286673152" class="bloop_sign"><div style="font-family:helvetica,arial;font-size:13px">--&nbsp;<br>Adrian Zubarev<br>Sent with Airmail</div></div> <br><p class="airmail_on">Am 2. Februar 2017 um 14:39:43, Daniel Duan (<a href="mailto:daniel@duan.org">daniel@duan.org</a>) schrieb:</p> <blockquote type="cite" class="clean_bq"><span><div dir="auto"><div></div><div>



<title></title>


<div>This has been answered in various forms in the thread. Short
answer: yes.</div>
<div><br>
On Feb 2, 2017, at 2:05 AM, Adrian Zubarev &lt;<a href="mailto:adrian.zubarev@devandartist.com">adrian.zubarev@devandartist.com</a>&gt;
wrote:<br>
<br></div>
<blockquote type="cite">
<div>

<div class="bloop_markdown">
<p>Is that correct that this proposal will add some sort of
overloading enum cases by different labels?</p>
<pre><code class="swift">enum Foo {
    case foo(a: Int)
    case foo(a: Int, b: Int)
}   
</code></pre>
<p>Is <code>Foo</code> a valid enum after this proposal?</p>
</div>
<div class="bloop_original_html">

<div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">
<br></div>
<br>
<div id="bloop_sign_1486029767109051904" class="bloop_sign">
<div style="font-family:helvetica,arial;font-size:13px">
--&nbsp;<br>
Adrian Zubarev<br>
Sent with Airmail</div>
</div>
<br>
<p class="airmail_on">Am 19. Januar 2017 um 19:37:50, Daniel Duan
via swift-evolution (<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>)
schrieb:</p>
<blockquote type="cite" class="clean_bq">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
<div><span>Hi all,</span>
<div class=""><span><br class=""></span></div>
<div class=""><span>Here’s a short proposal for fixing an
inconsistency in Swift’s enum. Please share you feedback
:)</span></div>
<div class=""><span><br class=""></span></div>
<div class=""><span>(Updating/rendered version:&nbsp;<a href="https://github.com/dduan/swift-evolution/blob/compound-names-for-enum-cases/proposals/NNNN-Compound-Names-For-Enum-Cases.md" class="">https://github.com/dduan/swift-evolution/blob/compound-names-for-enum-cases/proposals/NNNN-Compound-Names-For-Enum-Cases.md</a>)</span></div>
<div class=""><span><br class=""></span></div>
<div class=""><span><br class=""></span></div>
<div class="">
<div class=""><span>## Introduction</span></div>
<div class=""><span><br class=""></span></div>
<div class=""><span>Argument labels are part of its function's
declaration name. An enum case</span></div>
<div class=""><span>declares a function that can be used to
construct enum values. For cases with</span></div>
<div class=""><span>associated values, their labels should be part
of the constructor name, similar</span></div>
<div class=""><span>to "normal" function and methods. In Swift 3,
however, this is not true. This</span></div>
<div class=""><span>proposal aim to change that.</span></div>
<div class=""><span><br class=""></span></div>
<div class=""><span>## Motivation</span></div>
<div class=""><span><br class=""></span></div>
<div class=""><span>After SE-0111, Swift function's fully qualified
name consists of its base name</span></div>
<div class=""><span>and all argument labels. As a example, one can
invoke a function with its</span></div>
<div class=""><span>fully name:</span></div>
<div class=""><span><br class=""></span></div>
<div class=""><span>```swift</span></div>
<div class=""><span>func f(x: Int, y: Int) {}</span></div>
<div class=""><span><br class=""></span></div>
<div class=""><span>f(x: y:)(0, 0) // Okay, this is equivalent to
f(x: 0, y: 0)</span></div>
<div class=""><span>```</span></div>
<div class=""><span><br class=""></span></div>
<div class=""><span>This, however, is not true when enum cases with
associated value were</span></div>
<div class=""><span>constructed:</span></div>
<div class=""><span><br class=""></span></div>
<div class=""><span>```swift</span></div>
<div class=""><span>enum Foo {</span></div>
<div class=""><span>&nbsp; &nbsp; case bar(x: Int, y:
Int)</span></div>
<div class=""><span>}</span></div>
<div class=""><span><br class=""></span></div>
<div class=""><span>Foo.bar(x: y:)(0, 0) // Does not compile as of
Swift 3</span></div>
<div class=""><span>```</span></div>
<div class=""><span><br class=""></span></div>
<div class=""><span>Here, the declared name for the case is `foo`;
it has a tuple with two labeled</span></div>
<div class=""><span>fields as its associated value. `x` and `y`
aren't part of the case name. This</span></div>
<div class=""><span>inconsistency may surprise some
users.</span></div>
<div class=""><span><br class=""></span></div>
<div class=""><span>Using tuple to implement associated value also
limits us from certain layout</span></div>
<div class=""><span>optimizations as each payload need to be a
tuple first, as opposed to simply be</span></div>
<div class=""><span>unique to the enum.</span></div>
<div class=""><span><br class=""></span></div>
<div class=""><span>## Proposed solution</span></div>
<div class=""><span><br class=""></span></div>
<div class=""><span>Include labels in enum case's declaration name.
In the last example, `bar`'s</span></div>
<div class=""><span>full name would become `bar(x:y:)`, `x` and `y`
will no longer be labels in a</span></div>
<div class=""><span>tuple. The compiler may also stop using tuple
to represent associated values.</span></div>
<div class=""><span><br class=""></span></div>
<div class=""><span>## Detailed design</span></div>
<div class=""><span><br class=""></span></div>
<div class=""><span>When labels are present in enum cases, they are
now part of case's declared name</span></div>
<div class=""><span>instead of being labels for fields in a tuple.
In details, when constructing an</span></div>
<div class=""><span>enum value with the case name, label names must
either be supplied in the</span></div>
<div class=""><span>argument list it self, or as part of the full
name.</span></div>
<div class=""><span><br class=""></span></div>
<div class=""><span>```swift</span></div>
<div class=""><span>Foo.bar(x: 0, y: 0) // Okay, the Swift 3
way.</span></div>
<div class=""><span>Foo.bar(x: y:)(0, 0) // Equivalent to the
previous line.</span></div>
<div class=""><span>Foo.bar(x: y:)(x: 0, y: 0) // This would be an
error, however.</span></div>
<div class=""><span>```</span></div>
<div class=""><span><br class=""></span></div>
<div class=""><span>Note that since the labels aren't part of a
tuple, they no longer participate in</span></div>
<div class=""><span>type checking, similar to
functions:</span></div>
<div class=""><span><br class=""></span></div>
<div class=""><span>```swift</span></div>
<div class=""><span>let f = Foo.bar // f has type (Int, Int) -&gt;
Foo</span></div>
<div class=""><span>f(0, 0) // Okay!</span></div>
<div class=""><span>f(x: 0, y: 0) // Won't compile.</span></div>
<div class=""><span>```</span></div>
<div class=""><span><br class=""></span></div>
<div class=""><span>## Source compatibility</span></div>
<div class=""><span><br class=""></span></div>
<div class=""><span>Since type-checking rules on labeled tuple is
stricter than that on function</span></div>
<div class=""><span>argument labels, existing enum value
construction by case name remain valid.</span></div>
<div class=""><span>This change is source compatible with Swift
3.</span></div>
<div class=""><span><br class=""></span></div>
<div class=""><span>## Effect on ABI stability and
resilience</span></div>
<div class=""><span><br class=""></span></div>
<div class=""><span>This change introduces compound names for enum
cases, which affects their</span></div>
<div class=""><span>declaration's name mangling.</span></div>
<div class=""><span><br class=""></span></div>
<div class=""><span>The compiler may also choose to change enum
payload's representation from tuple.</span></div>
<div class=""><span>This may open up more space for improving
enum's memory layout.</span></div>
<div class=""><span><br class=""></span></div>
<div class=""><span>## Alternatives considered</span></div>
<div class=""><span><br class=""></span></div>
<div class=""><span>Keep current behaviors, which means we live
with the inconsistency.</span></div>
</div>
<div class=""><span><br class=""></span></div>
<span>_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>

<a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</span></div>
</div>
</blockquote>
</div>
<div class="bloop_markdown"></div>
</div>
</blockquote>


</div></div></span></blockquote></div><div class="bloop_markdown"><p></p></div></body></html>