<div dir="ltr">I should clarify. I mean that they&#39;re like types in that they have a unique scoped name with fields. A union with cases with associated values is a sum types of product types. Obviously, they can&#39;t be used like &quot;real&quot; types as formal parameters, etc.<div><br></div><div>I don&#39;t see them as values or initializers but very constrained types. For instance, in C you could have something like:</div><div><br></div><div><div>struct Foo {                                                                       </div><div>    int tag;                                                               </div><div>                                                                                   </div><div>    union {                                                                        </div><div>        struct Bar {                                                               </div><div>           int x;                                                                  </div><div>           int y;                                                                  </div><div>        } bar;                                                                     </div><div>                                                                                   </div><div>        struct Baz {                                                               </div><div>          double a;                                                                </div><div>          double b;                                                                </div><div>        } baz;                                                                     </div><div>    } data;                                                                        </div><div>}; </div><div><br></div><div>which would be equivalent to Swift&#39;s:<br><br>enum Foo {</div><div>    case Bar(x: Int, y: Int)</div><div>    case Baz(a: Double, b: Double)</div><div>}</div><div><br></div><div>Bar and Baz in the C code above are actual types just unusable outside of the sum type (tagged union). If that&#39;s not similar to Swift, please correct me.</div><div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jan 26, 2016 at 2:02 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:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><br>
on Sun Jan 24 2016, Thorsten Seitz &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br>
<br>
&gt; Yes, I think they are a lot like sum (or union) types. In Ceylon enums<br>
&gt; actually are modeled as union types (there is no specific enum<br>
&gt; syntax).<br>
<br>
Enums in Swift are exactly that; Ceylon chose the name &quot;union;&quot; we chose<br>
&quot;enum.&quot;  But Trent is saying that enum *cases* are like types.<br>
<br>
&gt; -Thorsten<br>
&gt;<br>
&gt;&gt; Am 23.01.2016 um 19:57 schrieb Trent Nadeau via swift-evolution<br>
&gt;&gt; &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt;:<br>
<span class="">&gt;&gt;<br>
&gt;&gt; While enum cases may not be types from a compiler perspective, I think they are from a user&#39;s level.<br>
&gt;&gt;<br>
&gt;&gt; Consider:<br>
&gt;&gt;<br>
&gt;&gt; enum MyError: ErrorType {<br>
&gt;&gt;     case FileError(fileName: String)<br>
&gt;&gt;     case SocketError(ipAddr: String, port: Int16)<br>
&gt;&gt; }<br>
&gt;&gt;<br>
&gt;&gt; From a compiler perspective, it&#39;s a tagged union (one type), but for<br>
&gt;&gt; a user this is a set of disjoint types that happen to share the same<br>
&gt;&gt; space and have exhaustiveness checking, etc. It&#39;s a much more<br>
&gt;&gt; efficient and convenient version of multiple structs or tuples.<br>
&gt;&gt;<br>
</span><span class="">&gt;&gt; On Sat, Jan 23, 2016 at 1:49 PM, Joe Groff<br>
&gt;&gt; &lt;<a href="mailto:jgroff@apple.com">jgroff@apple.com</a><br>
</span><span class="">&gt;&gt; &lt;mailto:<a href="mailto:jgroff@apple.com">jgroff@apple.com</a>&gt;&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; &gt; On Jan 23, 2016, at 10:24 AM, Trent Nadeau<br>
&gt;&gt; &gt; &lt;<a href="mailto:tanadeau@gmail.com">tanadeau@gmail.com</a><br>
</span><span class="">&gt;&gt; &gt; &lt;mailto:<a href="mailto:tanadeau@gmail.com">tanadeau@gmail.com</a>&gt;&gt; wrote:<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; I think it makes sense for enum cases to be UpperCamelCase as they<br>
&gt;&gt; &gt; can be thought of as scoped types (singleton types in the case of<br>
&gt;&gt; &gt; cases with no associated types).<br>
&gt;&gt;<br>
&gt;&gt; They aren&#39;t, though. I don&#39;t see much value in setting false expectations.<br>
&gt;&gt;<br>
&gt;&gt; -Joe<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; --<br>
</span>&gt;&gt; Trent Nadeau<br>
<div class=""><div class="h5">&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;<br>
&gt; _______________________________________________<br>
&gt; swift-evolution mailing list<br>
&gt; <a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
&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>
<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></div></div></div>