<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Oct 12, 2016 at 10:31 AM, Karl <span dir="ltr">&lt;<a href="mailto:razielim@gmail.com" target="_blank">razielim@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>I think he wants convenience accessors for the associated values; the problem is that in his example, he shouldn’t even be using associated values at all.</div><div>The example was about getting a size (a pair of numbers) based on the case of an enum.</div><div>In that case, you need to write a switch statement to return the size. You can either do that every time you need a size from the enum, or you can extend the enum and make it a computed property.</div><div><br></div><div>I do sometimes wonder why we don’t have better accessors. We have the “if case let” thing, but that’s horrible. On the rare occasion where it’s appropriate, it always takes me 4 or 5 attempts to get the incantation correct (single equals!):</div><div><br></div><div>if case .anotherThing(let theError) = myValue {</div><div>    print(“oh, no! an error! \(theError)”)</div><div>}</div><div><br></div>Urf.</div></blockquote><div><br></div><div>I entirely agree with everything you just said. And FWIW, this really is the single most unwieldy incantation in all of Swift--and I think incantation is the right word here. I&#39;d love it if we could sugar to something like `if let theError = myValue.anotherThing?.associatedValue` or something, but of course we could bikeshed this yet again for ages to little end. Perhaps a topic for the coming spring.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><span class="HOEnZb"><font color="#888888">- Karl</font></span><div><div class="h5"><br><div><blockquote type="cite"><div>On 12 Oct 2016, at 17:12, Xiaodi Wu &lt;<a href="mailto:xiaodi.wu@gmail.com" target="_blank">xiaodi.wu@gmail.com</a>&gt; wrote:</div><br class="m_4191334291974452113Apple-interchange-newline"><div><br class="m_4191334291974452113Apple-interchange-newline"><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div class="gmail_quote" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">On Wed, Oct 12, 2016 at 10:07 AM, Karl via swift-evolution<span class="m_4191334291974452113Apple-converted-space"> </span><span dir="ltr">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-<wbr>evolution@swift.org</a>&gt;</span><span class="m_4191334291974452113Apple-converted-space"> </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">Not at all - his proposal looks like the enum cases have an associated value, when that is exactly what you _don’t_ want. It’s wasted storage because they have a handful of known values.<br><br>It’s a PITA, I get it, I go through it all the time, too; but really this is the very definition of a computed property. There is nothing to be stored here. Meanwhile, something like:<br><br>enum Something {<br>   case oneThing(UIView)<br>   case anotherThing(Error)<br>   case yetAnotherThing(Int)<br>}<br><br>…which is dangerously similar to Braeden’s example, really does store an instance of UIView or Error or Int along with it. The size of the value is the maximum of those, plus a couple of bits to record which case it is and what the type of the payload is.<br><br>Confusing those things just because you don’t like writing switch statements would be bad, IMO. It’s not that much code, and once you’ve done a few of them you can make it quite compact. If you have a boatload of associated values, wrap them in a struct.<br>Some more convenient generated accessors for the associated data might be nice, but that’s been proposed and discussed to death. Others who have followed the lists more closely can maybe tell you why we don’t have an accepted proposal for it.<br></blockquote><div><br></div><div>I agree with Karl on this. There should be clarity here as to what&#39;s proposed. If it&#39;s a change to how enums are laid out in memory, then you&#39;ll need to show we&#39;re not sacrificing performance/size in the overwhelmingly more common use cases, and why the extra storage is useful in the first place; if it&#39;s syntactic sugar, that has already been proposed multiple times and really isn&#39;t in scope for this phase of Swift 4--nor does it really enable any new use cases not possible now.</div><div> </div><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">- Karl<br><div class="m_4191334291974452113m_4389194000071985353HOEnZb"><div class="m_4191334291974452113m_4389194000071985353h5"><br>&gt; On 12 Oct 2016, at 13:52, Rien &lt;<a href="mailto:Rien@Balancingrock.nl" target="_blank">Rien@Balancingrock.nl</a>&gt; wrote:<br>&gt;<br>&gt; I read Braeden’s example such that this proposal is in reality “just” syntactic sugar. AFAIAC it does not change how enums are implemented after compilation.<br>&gt;<br>&gt; Like sugar, it makes working with enums clearer and therefore easier. All initialisation values are defined right there with the ‘case’ instead of hidden in a tree of multiple ‘var’s.<br>&gt; While I was sceptical about this proposal, Braeden’s example makes it a +1.<br>&gt;<br>&gt; Rien.<br>&gt;<br>&gt; Btw: I made the almost identical suggestion you did ;-)<br>&gt;<br>&gt;<br>&gt;&gt; On 12 Oct 2016, at 13:31, Karl &lt;<a href="mailto:razielim@gmail.com" target="_blank">razielim@gmail.com</a>&gt; wrote:<br>&gt;&gt;<br>&gt;&gt; I very much disagree with the proposal, and all of the things supporting it (like deriving enums from other types and whatnot). I think you need to take a step up from caring about whether it’s a struct or enum and think about what you are trying to model; that will guide you towards the correct type(s) to use.<br>&gt;&gt;<br>&gt;&gt; You have only shown a handful of fixed size values, so I would suggest a computed property in your case:<br>&gt;&gt;<br>&gt;&gt; enum FixedSize {<br>&gt;&gt; case small<br>&gt;&gt; case medium<br>&gt;&gt; case large<br>&gt;&gt;<br>&gt;&gt; struct Size { let width : Int; let height: Int }<br>&gt;&gt;<br>&gt;&gt; var size : Size {<br>&gt;&gt;   switch self {<br>&gt;&gt;       case .small: return Size(width: 30, height: 30)<br>&gt;&gt;       // … etc<br>&gt;&gt;   }<br>&gt;&gt; }<br>&gt;&gt; }<br>&gt;&gt;<br>&gt;&gt; There is no need for these sizes to be stored at all. If you want them baked in to your enum’s values, clearly you expect them to be specific values. It’s more efficient to just drop the stored data altogether in this case; this enum will get lowered in to single byte, which is more efficient to store and transport.<br>&gt;&gt;<br>&gt;&gt; Karl<br>&gt;&gt;<br>&gt;&gt;&gt; On 12 Oct 2016, at 13:15, Mateusz Malczak via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br>&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt; Mateusz, you lost me with “store some extra data”.<br>&gt;&gt;&gt;&gt; Does that mean something extra besides the code that Braeden suggested?<br>&gt;&gt;&gt;<br>&gt;&gt;&gt; What I meant by “store some extra data” was, to be able to define<br>&gt;&gt;&gt; immutable properties of any type, as a part of enum instead of<br>&gt;&gt;&gt; defining getters witch switches. I think Braeden example explains the<br>&gt;&gt;&gt; whole idea of that proposal.<br>&gt;&gt;&gt;<br>&gt;&gt;&gt; --<br>&gt;&gt;&gt; | Mateusz Malczak<br>&gt;&gt;&gt;<br>&gt;&gt;&gt;<br>&gt;&gt;&gt; 2016-10-12 8:42 GMT+02:00 Rien &lt;<a href="mailto:Rien@balancingrock.nl" target="_blank">Rien@balancingrock.nl</a>&gt;:<br>&gt;&gt;&gt;&gt; I’d give a +1 for the suggestion of Braeden.<br>&gt;&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt; Mateusz, you lost me with “store some extra data”.<br>&gt;&gt;&gt;&gt; Does that mean something extra besides the code that Braeden suggested?<br>&gt;&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt; Rien.<br>&gt;&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt;&gt; On 12 Oct 2016, at 00:13, Mateusz Malczak via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br>&gt;&gt;&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt;&gt; That&#39;s exactly what this proposal is about. I would like to<br>&gt;&gt;&gt;&gt;&gt; keep all enum properties but add an extra feature, so that enums can<br>&gt;&gt;&gt;&gt;&gt; store some extra data.<br>&gt;&gt;&gt;&gt;&gt; --<br>&gt;&gt;&gt;&gt;&gt; | Mateusz Malczak<br>&gt;&gt;&gt;&gt;&gt; +-----------------------------<wbr>--<br>&gt;&gt;&gt;&gt;&gt; |<span class="m_4191334291974452113Apple-converted-space"> </span><a href="mailto:mateusz@malczak.info" target="_blank">mateusz@malczak.info</a><br>&gt;&gt;&gt;&gt;&gt; |<span class="m_4191334291974452113Apple-converted-space"> </span><a href="http://malczak.info/" rel="noreferrer" target="_blank">http://malczak.info</a><br>&gt;&gt;&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt;&gt; 2016-10-11 23:42 GMT+02:00 Braeden Profile &lt;<a href="mailto:jhaezhyr12@gmail.com" target="_blank">jhaezhyr12@gmail.com</a>&gt;:<br>&gt;&gt;&gt;&gt;&gt;&gt; So, just to recap, the proposed solution is to help enums expose associated<br>&gt;&gt;&gt;&gt;&gt;&gt; values via properties, and is not to create enums that are open to extra<br>&gt;&gt;&gt;&gt;&gt;&gt; unnamed cases (RectSize(width:0,height:10))?<wbr> <span class="m_4191334291974452113Apple-converted-space"> </span>What I see is that enums would<br>&gt;&gt;&gt;&gt;&gt;&gt; still maintain their standing where an instance is just a selection of a<br>&gt;&gt;&gt;&gt;&gt;&gt; finite number of options, possibly with data attached.  In proposal 1, we<br>&gt;&gt;&gt;&gt;&gt;&gt; want some sort of syntax where this…<br>&gt;&gt;&gt;&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt;&gt;&gt; enum RectSize<br>&gt;&gt;&gt;&gt;&gt;&gt; {<br>&gt;&gt;&gt;&gt;&gt;&gt; let height:Int<br>&gt;&gt;&gt;&gt;&gt;&gt; let width:Int<br>&gt;&gt;&gt;&gt;&gt;&gt; case small(width: 30, height: 30)<br>&gt;&gt;&gt;&gt;&gt;&gt; case medium(width: 60, height: 60)<br>&gt;&gt;&gt;&gt;&gt;&gt; case large(width: 120, height: 120)<br>&gt;&gt;&gt;&gt;&gt;&gt; }<br>&gt;&gt;&gt;&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt;&gt;&gt; …is syntactically just like writing this…<br>&gt;&gt;&gt;&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt;&gt;&gt; enum RectSize<br>&gt;&gt;&gt;&gt;&gt;&gt; {<br>&gt;&gt;&gt;&gt;&gt;&gt; case small<br>&gt;&gt;&gt;&gt;&gt;&gt; case medium<br>&gt;&gt;&gt;&gt;&gt;&gt; case large<br>&gt;&gt;&gt;&gt;&gt;&gt; var height:Int<br>&gt;&gt;&gt;&gt;&gt;&gt; {<br>&gt;&gt;&gt;&gt;&gt;&gt;   switch self<br>&gt;&gt;&gt;&gt;&gt;&gt;   {<br>&gt;&gt;&gt;&gt;&gt;&gt;      case .small: return 30<br>&gt;&gt;&gt;&gt;&gt;&gt;      case .medium: return 60<br>&gt;&gt;&gt;&gt;&gt;&gt;      case .large: return 90<br>&gt;&gt;&gt;&gt;&gt;&gt;   }<br>&gt;&gt;&gt;&gt;&gt;&gt; }<br>&gt;&gt;&gt;&gt;&gt;&gt; let width:Int<br>&gt;&gt;&gt;&gt;&gt;&gt; {<br>&gt;&gt;&gt;&gt;&gt;&gt;   switch self<br>&gt;&gt;&gt;&gt;&gt;&gt;   {<br>&gt;&gt;&gt;&gt;&gt;&gt;      case .small: return 30<br>&gt;&gt;&gt;&gt;&gt;&gt;      case .medium: return 60<br>&gt;&gt;&gt;&gt;&gt;&gt;      case .large: return 90<br>&gt;&gt;&gt;&gt;&gt;&gt;   }<br>&gt;&gt;&gt;&gt;&gt;&gt; }<br>&gt;&gt;&gt;&gt;&gt;&gt; }<br>&gt;&gt;&gt;&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt;&gt;&gt; …right?  That way, you can write this:<br>&gt;&gt;&gt;&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt;&gt;&gt; var size: RectSize = .small<br>&gt;&gt;&gt;&gt;&gt;&gt; size.height == 30 // true<br>&gt;&gt;&gt;&gt;&gt;&gt; size.rawValue // Error:  RectSizes has no property `rawValue`.<br>&gt;&gt;&gt;&gt;&gt;&gt; size.height = 40 // Error:  `height` is immutable<br>&gt;&gt;&gt;&gt;&gt;&gt; size = .medium<br>&gt;&gt;&gt;&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt;&gt;&gt; I think we were also (separately) proposing to extend `rawValue` to take all<br>&gt;&gt;&gt;&gt;&gt;&gt; kinds of statically known values, like structs or tuples.  Doing that would<br>&gt;&gt;&gt;&gt;&gt;&gt; accomplish much of the same thing.<br>&gt;&gt;&gt;&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt;&gt;&gt; Someone fact-check me here!  I really do think something like this would be<br>&gt;&gt;&gt;&gt;&gt;&gt; a good idea, if we could get the right syntax.<br>&gt;&gt;&gt;&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt;&gt;&gt; On Oct 11, 2016, at 7:06 AM, Mateusz Malczak via swift-evolution<br>&gt;&gt;&gt;&gt;&gt;&gt; &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br>&gt;&gt;&gt;&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt;&gt;&gt; Hi,<br>&gt;&gt;&gt;&gt;&gt;&gt; I think we are here discussing two different aspects of introducing<br>&gt;&gt;&gt;&gt;&gt;&gt; this new feature - code syntax and underlying implementation.<br>&gt;&gt;&gt;&gt;&gt;&gt; In terms of code syntax I would go with first proposal as it seems to<br>&gt;&gt;&gt;&gt;&gt;&gt; me the simplest approach. When it comes to underlying implementation,<br>&gt;&gt;&gt;&gt;&gt;&gt; I can imagine that during compilation internal struct is created, as<br>&gt;&gt;&gt;&gt;&gt;&gt; well as any required property getters. This way you could get a<br>&gt;&gt;&gt;&gt;&gt;&gt; variation of rawValue implementation, at least from theoretical point<br>&gt;&gt;&gt;&gt;&gt;&gt; of view :D<br>&gt;&gt;&gt;&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt;&gt;&gt; --<br>&gt;&gt;&gt;&gt;&gt;&gt; | Mateusz Malczak<br>&gt;&gt;&gt;&gt;&gt;&gt; +-----------------------------<wbr>--<br>&gt;&gt;&gt;&gt;&gt;&gt; |<span class="m_4191334291974452113Apple-converted-space"> </span><a href="mailto:mateusz@malczak.info" target="_blank">mateusz@malczak.info</a><br>&gt;&gt;&gt;&gt;&gt;&gt; |<span class="m_4191334291974452113Apple-converted-space"> </span><a href="http://malczak.info/" rel="noreferrer" target="_blank">http://malczak.info</a><br>&gt;&gt;&gt;&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt;&gt;&gt; 2016-10-10 23:42 GMT+02:00 Haravikk &lt;<a href="mailto:swift-evolution@haravikk.me" target="_blank">swift-evolution@haravikk.me</a>&gt;:<br>&gt;&gt;&gt;&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt;&gt;&gt; On 10 Oct 2016, at 20:34, Mateusz Malczak &lt;<a href="mailto:mateusz@malczak.info" target="_blank">mateusz@malczak.info</a>&gt; wrote:<br>&gt;&gt;&gt;&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt;&gt;&gt; I know, but what I&#39;m saying is that this problem could be solved in the<br>&gt;&gt;&gt;&gt;&gt;&gt; multiple values case by allowing tuples as raw values for enums, since that<br>&gt;&gt;&gt;&gt;&gt;&gt; would allow you to specify both width and height. So it&#39;d look something<br>&gt;&gt;&gt;&gt;&gt;&gt; like this:<br>&gt;&gt;&gt;&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt;&gt;&gt; We have three different possible solution<br>&gt;&gt;&gt;&gt;&gt;&gt; 1. stored properties defined as part of enumeration type<br>&gt;&gt;&gt;&gt;&gt;&gt; enum RectSizes: MyRect<br>&gt;&gt;&gt;&gt;&gt;&gt; {<br>&gt;&gt;&gt;&gt;&gt;&gt; let height:Int<br>&gt;&gt;&gt;&gt;&gt;&gt; let width:Int<br>&gt;&gt;&gt;&gt;&gt;&gt; case Small(width: 30, height: 30)<br>&gt;&gt;&gt;&gt;&gt;&gt; case Medium(width: 60, height: 60)<br>&gt;&gt;&gt;&gt;&gt;&gt; case Large(width: 120, height: 120)<br>&gt;&gt;&gt;&gt;&gt;&gt; }<br>&gt;&gt;&gt;&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt;&gt;&gt; 2. struct as rawValue<br>&gt;&gt;&gt;&gt;&gt;&gt; struct MyRect<br>&gt;&gt;&gt;&gt;&gt;&gt; {<br>&gt;&gt;&gt;&gt;&gt;&gt; var height:Int<br>&gt;&gt;&gt;&gt;&gt;&gt; var width:Int<br>&gt;&gt;&gt;&gt;&gt;&gt; var area:Int {return height:Int*width}<br>&gt;&gt;&gt;&gt;&gt;&gt; }<br>&gt;&gt;&gt;&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt;&gt;&gt; enum RectSizes: MyRect<br>&gt;&gt;&gt;&gt;&gt;&gt; {<br>&gt;&gt;&gt;&gt;&gt;&gt; case Small(30,30)<br>&gt;&gt;&gt;&gt;&gt;&gt; case Medium(60,60)<br>&gt;&gt;&gt;&gt;&gt;&gt; case Large(120,120)<br>&gt;&gt;&gt;&gt;&gt;&gt; }<br>&gt;&gt;&gt;&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt;&gt;&gt; 3. tuples as rawValue<br>&gt;&gt;&gt;&gt;&gt;&gt; enum Format : (width:Int, height:Int) {<br>&gt;&gt;&gt;&gt;&gt;&gt; case small(30, 30)<br>&gt;&gt;&gt;&gt;&gt;&gt; case medium(60, 60)<br>&gt;&gt;&gt;&gt;&gt;&gt; case large(120, 120)<br>&gt;&gt;&gt;&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt;&gt;&gt; var width:Int { return self.rawValue.width }<br>&gt;&gt;&gt;&gt;&gt;&gt; var height:Int { return self.rawValue.height }<br>&gt;&gt;&gt;&gt;&gt;&gt; }<br>&gt;&gt;&gt;&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt;&gt;&gt; Solutions 2 and 3 are quire similar, to get value of a stored property<br>&gt;&gt;&gt;&gt;&gt;&gt; we need to use rawValue or define value getters. In addition in<br>&gt;&gt;&gt;&gt;&gt;&gt; solution 2 we define an additional data type just to be used as an<br>&gt;&gt;&gt;&gt;&gt;&gt; enumeration type rawValue type. In my opinion, first approach would be<br>&gt;&gt;&gt;&gt;&gt;&gt; a best solution, type definition is clear and self-explanatory because<br>&gt;&gt;&gt;&gt;&gt;&gt; it is similar to how enums/classes are defined.<br>&gt;&gt;&gt;&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt;&gt;&gt; --<br>&gt;&gt;&gt;&gt;&gt;&gt; | Mateusz Malczak<br>&gt;&gt;&gt;&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt;&gt;&gt; Actually I&#39;d say your option 2 here is more similar to option 1 (you seem to<br>&gt;&gt;&gt;&gt;&gt;&gt; be using a struct to define the stored properties instead). The issue here<br>&gt;&gt;&gt;&gt;&gt;&gt; is that storing properties conflicts with what you&#39;re actually doing, which<br>&gt;&gt;&gt;&gt;&gt;&gt; is storing case-specific values, which is what rawValue already does, it&#39;s<br>&gt;&gt;&gt;&gt;&gt;&gt; just too limited for your current use-case (multiple values).<br>&gt;&gt;&gt;&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt;&gt;&gt; The complete solution would be to introduce the concept of tuples as<br>&gt;&gt;&gt;&gt;&gt;&gt; literals (even though they can&#39;t currently conform to types); this would<br>&gt;&gt;&gt;&gt;&gt;&gt; make it a lot easier to support the use of any type as a fixed value for<br>&gt;&gt;&gt;&gt;&gt;&gt; each case (not just tuples). For example, say we introduced as new protocol:<br>&gt;&gt;&gt;&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt;&gt;&gt; protocol ExpressableByTuple {<br>&gt;&gt;&gt;&gt;&gt;&gt; associatedtype TupleType // somehow force this to be a tuple or<br>&gt;&gt;&gt;&gt;&gt;&gt; ExpressableByType type<br>&gt;&gt;&gt;&gt;&gt;&gt; init(tupleLiteral:TupleType)<br>&gt;&gt;&gt;&gt;&gt;&gt; }<br>&gt;&gt;&gt;&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt;&gt;&gt; With a bit of magic all tuples could conform to this protocol with<br>&gt;&gt;&gt;&gt;&gt;&gt; themselves as the literal type, allowing us to use them as enum raw values;<br>&gt;&gt;&gt;&gt;&gt;&gt; likewise this could then be used to more easily enable any custom<br>&gt;&gt;&gt;&gt;&gt;&gt; struct/class for storage in enum cases, as instead of supporting their<br>&gt;&gt;&gt;&gt;&gt;&gt; constructors directly we can just support construction via a tuple literal.<br>&gt;&gt;&gt;&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt;&gt;&gt; My other reason I don&#39;t favour option 1, while it looks a bit prettier, is<br>&gt;&gt;&gt;&gt;&gt;&gt; that it&#39;s a bit confusing; enums have two types of stored properties, ones<br>&gt;&gt;&gt;&gt;&gt;&gt; that can be changed (and inspected) which is what you get when you declare<br>&gt;&gt;&gt;&gt;&gt;&gt; case small(Int, Int) for example, these are stored as part of the enum<br>&gt;&gt;&gt;&gt;&gt;&gt; itself (so in that example it&#39;s 17-bytes on a 64-bit system). However<br>&gt;&gt;&gt;&gt;&gt;&gt; rawValues are more like constants/static values, and don&#39;t increase the size<br>&gt;&gt;&gt;&gt;&gt;&gt; of the type, and I just feel that this is the right way to do what you&#39;re<br>&gt;&gt;&gt;&gt;&gt;&gt; proposing.<br>&gt;&gt;&gt;&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt;&gt;&gt; ______________________________<wbr>_________________<br>&gt;&gt;&gt;&gt;&gt;&gt; swift-evolution mailing list<br>&gt;&gt;&gt;&gt;&gt;&gt;<span class="m_4191334291974452113Apple-converted-space"> </span><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.<wbr>org</a><br>&gt;&gt;&gt;&gt;&gt;&gt;<span class="m_4191334291974452113Apple-converted-space"> </span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.<wbr>org/mailman/listinfo/swift-<wbr>evolution</a><br>&gt;&gt;&gt;&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt;&gt;&gt;<br>&gt;&gt;&gt;&gt;&gt; ______________________________<wbr>_________________<br>&gt;&gt;&gt;&gt;&gt; swift-evolution mailing list<br>&gt;&gt;&gt;&gt;&gt;<span class="m_4191334291974452113Apple-converted-space"> </span><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.<wbr>org</a><br>&gt;&gt;&gt;&gt;&gt;<span class="m_4191334291974452113Apple-converted-space"> </span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br>&gt;&gt;&gt;&gt;<br>&gt;&gt;&gt; ______________________________<wbr>_________________<br>&gt;&gt;&gt; swift-evolution mailing list<br>&gt;&gt;&gt;<span class="m_4191334291974452113Apple-converted-space"> </span><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>&gt;&gt;&gt;<span class="m_4191334291974452113Apple-converted-space"> </span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br>&gt;&gt;<br>&gt;<br><br>______________________________<wbr>_________________<br>swift-evolution mailing list<br><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailma<wbr>n/listinfo/swift-evolution</a></div></div></blockquote></div></div></blockquote></div><br></div></div></div></div></blockquote></div><br></div></div>