<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Feb 16, 2017, at 5:00 PM, Karl Wagner &lt;<a href="mailto:razielim@gmail.com" class="">razielim@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On 16 Feb 2017, at 23:44, Matthew Johnson via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">I have been thinking a lot about enums and value subtyping lately and decided to write down the ideas I’ve been thinking about. &nbsp;The result is a manifesto-style document that explores a broad landscape of features that could eventually lead to proposals (at the right time, of course).<br class=""><br class="">I’m presenting this document to the list now mostly because I am not sure which of these features (if any) might be relevant to ABI stability, particularly with respect to standard library APIs. &nbsp;I do not wish to distract the list from the focus on Swift 4, phase 1. &nbsp;Let’s try not to get distracted by exciting ideas that won’t be in scope until at least phase 2. &nbsp;Feel free to send feedback off list if you’re interested in discussing ideas that may not be relevant to Swift evolution at this time.<br class=""><br class="">Because this document covers a pretty broad range of topics it might be a good idea to start a new thread before jumping in to discussion about a specific aspect of it. &nbsp;Please consider doing that if it is relevant before responding directly to this thread.<br class=""><br class="">As this is a relatively large document I am only providing a link: <a href="https://gist.github.com/anandabits/5b7f8e3836387e893e3a1197a4bf144d" class="">https://gist.github.com/anandabits/5b7f8e3836387e893e3a1197a4bf144d</a><br class=""><br class="">To whet your appetite, the topics covered include:<br class=""><br class="">* Definition of value subtyping<br class=""> &nbsp;&nbsp;* Transitivity of value subtypes<br class=""> &nbsp;&nbsp;* Generic supertype constraints<br class="">* Axiomatic value subtype relationships<br class="">* Enums: Value Subtype Relationships by definition<br class=""> &nbsp;&nbsp;* Nominal case types<br class=""> &nbsp;&nbsp;* Nominal unions<br class=""> &nbsp;&nbsp;* Generic enums and Optional<br class=""> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* Cases with unbound generic arguments<br class=""> &nbsp;&nbsp;* Structural Unions<br class=""> &nbsp;&nbsp;* Enum subtypes<br class=""> &nbsp;&nbsp;* Inline enum subtypes<br class=""> &nbsp;&nbsp;* Inline generic enum subtypes<br class=""> &nbsp;&nbsp;* Conditional cases (and GADTs)<br class=""> &nbsp;&nbsp;* Inline case types<br class=""> &nbsp;&nbsp;* Nominal cases with inline types<br class=""> &nbsp;&nbsp;* Case type implementation sharing<br class=""> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* Shared stored properties<br class=""> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* Subenum stored properties<br class=""> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* Shared methods and computed properties<br class="">* User-defined case patterns<br class="">_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div></div></blockquote></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><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(247, 247, 247); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-break: normal; color: rgb(51, 51, 51);" class=""><span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">enum</span> <span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">IntOrString</span>: <span class="pl-e" style="box-sizing: border-box; color: rgb(121, 93, 163);"><span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">Int</span> </span>| <span class="pl-e" style="box-sizing: border-box; color: rgb(121, 93, 163);"><span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">String</span> </span>{
  <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">case</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">Int</span>
  <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">case</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">String</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"></span>}

<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">func</span> <span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">takesAnonymousUnion</span>(<span class="pl-smi" style="box-sizing: border-box;"><span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">intOrString</span></span>: <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">Int</span> | <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">String</span>) {}</pre><div class=""><br class=""></div></div><div class=""><div class="">Haven’t been through it all, just pointing out that “Structural unions” and anonymous unions have been suggested and rejected before.</div></div></div></div></blockquote><div><br class=""></div><div>Thanks for taking a look at the document Karl.</div><div><br class=""></div><div>I understand and have followed the previous discussions regarding structural unions and alluded to them in the manifesto. &nbsp;I am not proposing anything directly in this document. &nbsp;I am only exploring ideas and observing how they logically follow from one another.</div><div><br class=""></div><div>My hope is that demonstrating how structural unions fit within the larger landscape of value subtyping will provide some context for possibly revisiting the structural union discussion in the future. &nbsp;Specifically, if we introduce nominal case types and nominal unions there would be a new basis and context for revisiting the discussion of structural unions. &nbsp;It certainly won’t happen prior to that. &nbsp;In any case, I think it’s safe to say this is a topic that is definitely *not* in scope for Swift 4, phase 1. &nbsp;:)</div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><div class=""><br class=""></div><div class="">- Karl</div></div></div></div></blockquote></div><br class=""></body></html>