<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 Sep 9, 2017, at 12:36 PM, Matthew Johnson via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="content-type" content="text/html; charset=utf-8" class=""><div dir="auto" class=""><div class=""><br class=""><br class="">Sent from my iPad</div><div class=""><br class="">On Sep 9, 2017, at 11:42 AM, gs. <<a href="mailto:griotspeak@gmail.com" class="">griotspeak@gmail.com</a>> wrote:<br class=""><br class=""></div><blockquote type="cite" class=""><div class=""><meta http-equiv="content-type" content="text/html; charset=utf-8" class=""><div class="">How does fragility play into this? Does this only work for fragile (closed) and internal/private/fileprivate enums?<br class=""></div></div></blockquote><div class=""><br class=""></div><div class="">That's a great question. I think it would have to have that limitation. Using Jordan's terminology, by definition a nonexhaustive cannot provide a complete list of all values.</div></div></div></blockquote><div><br class=""></div><div>The runtime “knows” (or could be made to know) all the cases at any given moment in time (ignoring runtime-loaded modules, should they ever be supported). This is actually a strong argument for the creation of this feature. It would be impossible for such a list to be maintained manually. Making the list available somehow at compile time would almost guarantee a source-breaking/ABI-breaking change in the future. This raises a question: would models want anything other than the complete list of cases at runtime? For example, the module containing the root enum may have a use for the cases just defined within that module. I propose that the feature be defined to include all cases at runtime and that discussions of partial lists of cases be deferred until a use is found for them.</div><div><br class=""></div><blockquote type="cite" class=""><div class=""><div dir="auto" class=""><br class=""><blockquote type="cite" class=""><div class=""><div class=""><br class="">TJ </div><div class=""><br class="">On Sep 9, 2017, at 15:23, Matthew Johnson via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:<br class=""><br class=""></div><blockquote type="cite" class=""><div class=""><meta http-equiv="content-type" content="text/html; charset=utf-8" class=""><div class=""><br class=""><br class="">Sent from my iPad</div><div class=""><br class="">On Sep 9, 2017, at 7:33 AM, Brent Royal-Gordon <<a href="mailto:brent@architechies.com" class="">brent@architechies.com</a>> wrote:<br class=""><br class=""></div><blockquote type="cite" class=""><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div class=""><blockquote type="cite" class=""><div class="">On Sep 8, 2017, at 5:14 PM, Xiaodi Wu via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><span 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; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Here, people just want an array of all cases. Give them an array of all cases. When it's not possible (i.e., in the case of cases with associated values), don't do it.</span></div></blockquote></div><div class=""><br class=""></div><div class="">I agree it should be Int-indexed; that seems to be what people want from this.</div><div class=""><br class=""></div><div class="">I seem to recall that there is information about the available enum cases in the module metadata. If so, and if we're willing to lock that in as part of the ABI design, I think we should write—or at least allow for—a custom Int-indexed collection, because this may allow us to recurse into associated value types. If we aren't going to have suitable metadata, though, I agree we should just use an Array. There are pathological cases where instantiating a large Array might be burdensome, but sometimes you just have to ignore the pathological cases.</div><div class=""><br class=""></div><div class="">(The "infinite recursion" problem with associated values is actually relatively easy to solve, by the way: Don't allow, or at least don't generate, `ValuesEnumerable` conformance on enums with `indirect` cases.)</div></div></blockquote><div class=""><br class=""></div><div class="">This is the direction I think makes the most sense in terms of how we should approach synthesis. The open question in my mind is what the exact requirement of the protocol should be. Should it exactly match what we synthesize (`[Self]` or an associated `Collection where Iterator.Element == Self, Index == Int`) or whether the protocol should have a more relaxed requirement of `Sequence where Iterator.Element == Self` like Tony proposed.</div><br class=""><blockquote type="cite" class=""><div class=""><br class=""><div class="">
<span class="Apple-style-span" style="border-collapse: separate; font-family: Helvetica; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-variant-east-asian: normal; font-variant-position: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; border-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-stroke-width: 0px;"><div class=""><div style="font-size: 12px; " class="">-- </div><div style="font-size: 12px; " class="">Brent Royal-Gordon</div><div style="font-size: 12px; " class="">Architechies</div></div></span>
</div>
<br class=""></div></blockquote></div></blockquote><blockquote type="cite" class=""><div class=""><span class="">_______________________________________________</span><br class=""><span class="">swift-evolution mailing list</span><br class=""><span class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a></span><br class=""><span class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br class=""></div></blockquote></div></blockquote></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></body></html>