<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=""><div class="">From what I understand, enums normally are represented internally by an offset — that is their truth. With RawRepresentable enums, you are saying “no, I want the truth to be something else”. But it seems that they are still represented internally by an offset, so you can’t reorder a RawRepresentable enum’s cases and maintain ABI compatibility either.</div><div class=""><br class=""></div><div class="">So what you are saying about the order of cases being an intrinsic part of an enum does make sense. I’m not sure if can still lead to confusing / fragile code though.</div><div class=""><br class=""></div><div class="">Patrick</div><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">On 2 Jun 2016, at 10:17 PM, Leonardo Pessoa &lt;<a href="mailto:me@lmpessoa.com" class="">me@lmpessoa.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 class=""><div class=""><div style="font-family: Calibri,sans-serif; font-size: 11pt;" class="">There are several ways to solve this, which IMO is a basic functionality of enums, writing code that is currently possible and works. But that's the issue, you still have to write code to have a basic functionally. I don't remember not being able to do this out-of-the-box in any language I worked with.<br class=""><br class="">L</div></div><div dir="ltr" class=""><hr class=""><span style="font-family: Calibri,sans-serif; font-size: 11pt; font-weight: bold;" class="">From: </span><span style="font-family: Calibri,sans-serif; font-size: 11pt;" class=""><a href="mailto:pgwsmith@gmail.com" class="">Patrick Smith</a></span><br class=""><span style="font-family: Calibri,sans-serif; font-size: 11pt; font-weight: bold;" class="">Sent: </span><span style="font-family: Calibri,sans-serif; font-size: 11pt;" class="">‎02/‎06/‎2016 02:07 AM</span><br class=""><span style="font-family: Calibri,sans-serif; font-size: 11pt; font-weight: bold;" class="">To: </span><span style="font-family: Calibri,sans-serif; font-size: 11pt;" class=""><a href="mailto:brent@architechies.com" class="">Brent Royal-Gordon</a></span><br class=""><span style="font-family: Calibri,sans-serif; font-size: 11pt; font-weight: bold;" class="">Cc: </span><span style="font-family: Calibri,sans-serif; font-size: 11pt;" class=""><a href="mailto:me@lmpessoa.com" class="">Leonardo Pessoa</a>; <a href="mailto:swift-evolution@swift.org" class="">swift-evolution</a></span><br class=""><span style="font-family: Calibri,sans-serif; font-size: 11pt; font-weight: bold;" class="">Subject: </span><span style="font-family: Calibri,sans-serif; font-size: 11pt;" class="">Re: [swift-evolution] Working with enums by name</span><br class=""><br class=""></div>Great points Brent. I think the ValuesEnumerable method would be the most straight forward. Also, the number of cases are likely only going to be in range of 6–20, so iterating would be fine I think. People can create something like `Dictionary(Planet.allValues.enumerated().lazy.map{ ($1, $0) })` (I think that’s right) if they really need.<br class=""><br class=""><br class="">&gt; On 2 Jun 2016, at 2:40 PM, Brent Royal-Gordon via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class="">&gt; <br class="">&gt; Or the `ValuesEnumerable` proposal would give you a convenient, though slightly slow, way to do two-way lookup by order:<br class="">&gt; <br class="">&gt;         enum Planet: String, ValuesEnumerable {<br class="">&gt;                 var order: Int {<br class="">&gt;                         return Planet.allValues.index(of: self)!<br class="">&gt;                 }<br class="">&gt;                 init(order: Int) {<br class="">&gt;                         self = Planet.allValues[order]<br class="">&gt;                 }<br class="">&gt;                 case mercury, venus, …<br class="">&gt;         }<br class=""><br class=""></div></div></blockquote></div><br class=""></body></html>