<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 Dec 8, 2015, at 10:09 PM, Jacob Bandes-Storch <<a href="mailto:jtbandes@gmail.com" class="">jtbandes@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">Do you have any recommendations for where in the compiler this would happen, for those of us without thorough knowledge of all parts? What would the team need to see in a proposal for it to be sufficiently complete?<br class=""></div></blockquote><div><br class=""></div><div>This would slot into the same logic that synthesizes memberwise initializers on structs. That said, I think that hashing out the right user model and set of capabilities is the first place to start.</div><div><br class=""></div><div>-Chris</div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div class="gmail_quote"><div dir="ltr" class="">On Tue, Dec 8, 2015 at 10:05 PM Chris Lattner <<a href="mailto:clattner@apple.com" class="">clattner@apple.com</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br class="">
> On Dec 8, 2015, at 9:53 PM, Jacob Bandes-Storch via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>> wrote:<br class="">
><br class="">
> Enums are often used without associated values:<br class="">
><br class="">
> enum Attribute { case Title, Date }<br class="">
> enum Style { case Dark, Light }<br class="">
><br class="">
> In such cases, it's very useful to be able to iterate over all possible values. But you have to do it manually:<br class="">
><br class="">
> extension Attribute {<br class="">
> static var allValues: [Attribute] {<br class="">
> return [.Title, .Date] // imagine this x100, and not autogenerated :(<br class="">
> }<br class="">
> }<br class="">
><br class="">
> It would be nice if the compiler generated this for us. It doesn't have to be an Array, but any kind of SequenceType. Maybe something like "StaticCollection". Of course, this doesn't work in the general case, but I think simple enums are common enough that it might be worth doing.<br class="">
<br class="">
This is a commonly requested feature, and tons of people would support the ability to do this somehow. Similarly, for integer-backed enums, many people want to be able to know the “max” enum rawValue so they can index into them.<br class="">
<br class="">
-Chris<br class="">
<br class="">
</blockquote></div>
</div></blockquote></div><br class=""></body></html>