<div dir="ltr"><div>I think I understand where you&#39;re coming from now in that you can think of:<br></div><div><br></div><div><font face="monospace, monospace">enum Foo {<br></font></div><div><div><font face="monospace, monospace">    case Bar(x: Int, y: Int)</font></div><div><font face="monospace, monospace">    case Baz(a: Double, b: Double)</font></div></div><div><font face="monospace, monospace">}</font></div><div><br></div><div>as:</div><div><br></div><div><font face="monospace, monospace">struct Foo {</font></div><div><font face="monospace, monospace">    let Bar: (x: Int, y: Int)</font></div><div><font face="monospace, monospace">    let Baz: (a: Double, b: Double)</font></div><div><font face="monospace, monospace">}</font></div><div><br></div><div>with special handling for storage and pattern matching.</div><div><br></div><div>I was thinking of it more in terms of mapping to:<br><br><div><font face="monospace, monospace">struct Foo {</font></div><div><font face="monospace, monospace">    typealias Bar = </font><span style="font-family:monospace,monospace">(x: Int, y: Int)</span></div><div><font face="monospace, monospace">    typealias </font><span style="font-family:monospace,monospace">Baz = (a: Double, b: Double)</span></div><div><span style="font-family:monospace,monospace"><br></span></div><div><span style="font-family:monospace,monospace">    let storage: MagicStorageOfMaxSize</span></div><div><font face="monospace, monospace">}</font></div></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">with special handling for type use and pattern matching.</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">The former is probably closer to the implementation and is easier to explain. If that&#39;s the case, I&#39;m +1 on changing the case naming convention. The initial capital letter probably put &quot;type&quot; in my head in the first place along with ways of using enums from other languages like Ceylon:<br><br></font><pre class="" style="word-wrap:break-word;color:rgb(231,233,219);font-family:&#39;andale mono&#39;,&#39;lucida console&#39;,monospace;margin-top:0px;margin-bottom:0px;padding:10px;border:0px;font-size:14.5px;vertical-align:baseline;font-stretch:normal;line-height:1.5;background-color:rgb(47,30,46)"><code class="" style="font-family:Inconsolata,Monaco,Courier,monospace;margin:0px;padding:0px;border:0px;vertical-align:baseline;font-stretch:normal;line-height:1.5"><span class="" style="margin:0px;padding:0px;border:0px;font-weight:inherit;font-style:inherit;font-family:inherit;vertical-align:baseline;color:rgb(6,182,239)">abstract</span> <span class="" style="margin:0px;padding:0px;border:0px;font-weight:inherit;font-style:inherit;font-family:inherit;vertical-align:baseline;color:rgb(184,186,175)">class</span> <span class="" style="margin:0px;padding:0px;border:0px;font-weight:inherit;font-style:inherit;font-family:inherit;vertical-align:baseline;color:rgb(254,196,24)">Node</span>() <span class="" style="margin:0px;padding:0px;border:0px;font-weight:inherit;font-style:inherit;font-family:inherit;vertical-align:baseline;color:rgb(184,186,175)">of</span> <span class="" style="margin:0px;padding:0px;border:0px;font-weight:inherit;font-style:inherit;font-family:inherit;vertical-align:baseline;color:rgb(254,196,24)">Leaf</span> | <span class="" style="margin:0px;padding:0px;border:0px;font-weight:inherit;font-style:inherit;font-family:inherit;vertical-align:baseline;color:rgb(254,196,24)">Branch</span> {}

<span class="" style="margin:0px;padding:0px;border:0px;font-weight:inherit;font-style:inherit;font-family:inherit;vertical-align:baseline;color:rgb(184,186,175)">class</span> <span class="" style="margin:0px;padding:0px;border:0px;font-weight:inherit;font-style:inherit;font-family:inherit;vertical-align:baseline;color:rgb(254,196,24)">Leaf</span>(<span class="" style="margin:0px;padding:0px;border:0px;font-weight:inherit;font-style:inherit;font-family:inherit;vertical-align:baseline;color:rgb(6,182,239)">shared</span> <span class="" style="margin:0px;padding:0px;border:0px;font-weight:inherit;font-style:inherit;font-family:inherit;vertical-align:baseline;color:rgb(254,196,24)">Object</span> <span class="" style="margin:0px;padding:0px;border:0px;font-weight:inherit;font-style:inherit;font-family:inherit;vertical-align:baseline;color:rgb(239,97,85)">element</span>) 
        <span class="" style="margin:0px;padding:0px;border:0px;font-weight:inherit;font-style:inherit;font-family:inherit;vertical-align:baseline;color:rgb(184,186,175)">extends</span> <span class="" style="margin:0px;padding:0px;border:0px;font-weight:inherit;font-style:inherit;font-family:inherit;vertical-align:baseline;color:rgb(254,196,24)">Node</span>() {}

<span class="" style="margin:0px;padding:0px;border:0px;font-weight:inherit;font-style:inherit;font-family:inherit;vertical-align:baseline;color:rgb(184,186,175)">class</span> <span class="" style="margin:0px;padding:0px;border:0px;font-weight:inherit;font-style:inherit;font-family:inherit;vertical-align:baseline;color:rgb(254,196,24)">Branch</span>(<span class="" style="margin:0px;padding:0px;border:0px;font-weight:inherit;font-style:inherit;font-family:inherit;vertical-align:baseline;color:rgb(6,182,239)">shared</span> <span class="" style="margin:0px;padding:0px;border:0px;font-weight:inherit;font-style:inherit;font-family:inherit;vertical-align:baseline;color:rgb(254,196,24)">Node</span> <span class="" style="margin:0px;padding:0px;border:0px;font-weight:inherit;font-style:inherit;font-family:inherit;vertical-align:baseline;color:rgb(239,97,85)">left</span>, <span class="" style="margin:0px;padding:0px;border:0px;font-weight:inherit;font-style:inherit;font-family:inherit;vertical-align:baseline;color:rgb(6,182,239)">shared</span> <span class="" style="margin:0px;padding:0px;border:0px;font-weight:inherit;font-style:inherit;font-family:inherit;vertical-align:baseline;color:rgb(254,196,24)">Node</span> <span class="" style="margin:0px;padding:0px;border:0px;font-weight:inherit;font-style:inherit;font-family:inherit;vertical-align:baseline;color:rgb(239,97,85)">right</span>) 
        <span class="" style="margin:0px;padding:0px;border:0px;font-weight:inherit;font-style:inherit;font-family:inherit;vertical-align:baseline;color:rgb(184,186,175)">extends</span> <span class="" style="margin:0px;padding:0px;border:0px;font-weight:inherit;font-style:inherit;font-family:inherit;vertical-align:baseline;color:rgb(254,196,24)">Node</span>() {}</code></pre></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jan 26, 2016 at 7:49 PM, Dave Abrahams via swift-evolution <span dir="ltr">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br>
on Tue Jan 26 2016, Trent Nadeau &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br>
<br>
&gt; I should clarify. I mean that they&#39;re like types in that they have a<br>
&gt; unique scoped name with fields.<br>
<br>
</span>struct X {<br>
  static var y: Int = 3<br>
}<br>
<br>
X.y has a unique scoped name.  What&#39;s all this about fields?  I don&#39;t<br>
understand that part.<br>
<span class=""><br>
&gt; A union with cases with associated values is a sum types of product<br>
&gt; types. Obviously, they can&#39;t be used like &quot;real&quot; types as formal<br>
&gt; parameters, etc.<br>
&gt;<br>
&gt; I don&#39;t see them as values or initializers but very constrained types. For<br>
&gt; instance, in C you could have something like:<br>
&gt;<br>
&gt; struct Foo {<br>
&gt;<br>
&gt;     int tag;<br>
&gt;<br>
&gt;     union {<br>
&gt;<br>
&gt;         struct Bar {<br>
&gt;<br>
&gt;            int x;<br>
&gt;<br>
&gt;            int y;<br>
&gt;<br>
&gt;         } bar;<br>
&gt;<br>
&gt;         struct Baz {<br>
&gt;<br>
&gt;           double a;<br>
&gt;<br>
&gt;           double b;<br>
&gt;<br>
&gt;         } baz;<br>
&gt;<br>
&gt;     } data;<br>
&gt;<br>
&gt; };<br>
&gt;<br>
&gt; which would be equivalent to Swift&#39;s:<br>
&gt;<br>
&gt; enum Foo {<br>
&gt;     case Bar(x: Int, y: Int)<br>
&gt;     case Baz(a: Double, b: Double)<br>
&gt; }<br>
&gt;<br>
&gt; Bar and Baz in the C code above are actual types just unusable outside of<br>
&gt; the sum type (tagged union).<br>
<br>
</span>The fact that an anonymous union in C hides the types declared within is<br>
just a quirk of that language.  You didn&#39;t even need to name Bar and Baz<br>
in the `C&#39; code.  The Bar and Baz in your swift code are more similar to<br>
bar and baz (lowercase) as they are required in order to access members<br>
of the sum.<br>
<br>
FWIW, there&#39;s a strong proposal out there (which I support) to give<br>
enums optional properties, e.g.<br>
<br>
      if let (x,y) = someFoo.Bar { ... }<br>
      else if let (a,b) = someFoo.Baz { ... }<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
<br>
&gt; If that&#39;s not similar to Swift, please correct me.<br>
<br>
&gt;<br>
&gt; On Tue, Jan 26, 2016 at 2:02 PM, Dave Abrahams via swift-evolution &lt;<br>
&gt; <a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br>
&gt;<br>
&gt;&gt;<br>
&gt;&gt; on Sun Jan 24 2016, Thorsten Seitz<br>
&gt;&gt; &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; &gt; Yes, I think they are a lot like sum (or union) types. In Ceylon enums<br>
&gt;&gt; &gt; actually are modeled as union types (there is no specific enum<br>
&gt;&gt; &gt; syntax).<br>
&gt;&gt;<br>
&gt;&gt; Enums in Swift are exactly that; Ceylon chose the name &quot;union;&quot; we chose<br>
&gt;&gt; &quot;enum.&quot;  But Trent is saying that enum *cases* are like types.<br>
&gt;&gt;<br>
&gt;&gt; &gt; -Thorsten<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; Am 23.01.2016 um 19:57 schrieb Trent Nadeau via swift-evolution<br>
&gt;&gt; &gt;&gt; &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt;:<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; While enum cases may not be types from a compiler perspective, I think<br>
&gt;&gt; they are from a user&#39;s level.<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; Consider:<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; enum MyError: ErrorType {<br>
&gt;&gt; &gt;&gt;     case FileError(fileName: String)<br>
&gt;&gt; &gt;&gt;     case SocketError(ipAddr: String, port: Int16)<br>
&gt;&gt; &gt;&gt; }<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; From a compiler perspective, it&#39;s a tagged union (one type), but for<br>
&gt;&gt; &gt;&gt; a user this is a set of disjoint types that happen to share the same<br>
&gt;&gt; &gt;&gt; space and have exhaustiveness checking, etc. It&#39;s a much more<br>
&gt;&gt; &gt;&gt; efficient and convenient version of multiple structs or tuples.<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; On Sat, Jan 23, 2016 at 1:49 PM, Joe Groff<br>
&gt;&gt; &gt;&gt; &lt;<a href="mailto:jgroff@apple.com">jgroff@apple.com</a><br>
&gt;&gt; &gt;&gt; &lt;mailto:<a href="mailto:jgroff@apple.com">jgroff@apple.com</a>&gt;&gt; wrote:<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt; On Jan 23, 2016, at 10:24 AM, Trent Nadeau<br>
&gt;&gt; &gt;&gt; &gt; &lt;<a href="mailto:tanadeau@gmail.com">tanadeau@gmail.com</a><br>
&gt;&gt; &gt;&gt; &gt; &lt;mailto:<a href="mailto:tanadeau@gmail.com">tanadeau@gmail.com</a>&gt;&gt; wrote:<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt; I think it makes sense for enum cases to be UpperCamelCase as they<br>
&gt;&gt; &gt;&gt; &gt; can be thought of as scoped types (singleton types in the case of<br>
&gt;&gt; &gt;&gt; &gt; cases with no associated types).<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; They aren&#39;t, though. I don&#39;t see much value in setting false<br>
&gt;&gt; expectations.<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; -Joe<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; --<br>
&gt;&gt; &gt;&gt; Trent Nadeau<br>
&gt;&gt; &gt;&gt; _______________________________________________<br>
&gt;&gt; &gt;&gt; swift-evolution mailing list<br>
&gt;&gt; &gt;&gt; <a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
&gt;&gt; &gt;&gt; <a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; _______________________________________________<br>
&gt;&gt; &gt; swift-evolution mailing list<br>
&gt;&gt; &gt; <a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
&gt;&gt; &gt; <a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
&gt;&gt;<br>
&gt;&gt; --<br>
&gt;&gt; -Dave<br>
&gt;&gt;<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; swift-evolution mailing list<br>
&gt;&gt; <a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
&gt;&gt; <a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
&gt;&gt;<br>
<br>
--<br>
-Dave<br>
<br>
_______________________________________________<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" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Trent Nadeau</div>
</div>