<div dir="ltr">Would this work with enums imported from C/Obj-C code as well? Personally, I've worked with code that would benefit greatly from it. But I could imagine confusion if a C enum already defines "max" or "number of elements" as a member of the enum, and Swift imports .max as being one greater.<br><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature"><div dir="ltr"><div>Jacob<br></div></div></div></div>
<br><div class="gmail_quote">On Wed, Dec 9, 2015 at 10:19 AM, David Waite <span dir="ltr"><<a href="mailto:david@alkaline-solutions.com" target="_blank">david@alkaline-solutions.com</a>></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><div>There are a number of possible proposals for enhancements I see off the bat for “basic" enums (without associated data):</div><div><br></div><div>1. A generated implementation of SequenceType based on declaration order</div><div>2. A second interface or extension to the enum type could supply static max and min properties when the RawValue is Comparable</div></div><div>3. For enums with a String raw value, CustomStringConvertible and Streamable might make sense as well. You would likely want CustomDebugStringConvertible to also be defined to supply the original type-based value.</div><div><br></div><div>-DW</div><br><div><blockquote type="cite"><div><div class="h5"><div>On Dec 8, 2015, at 11:13 PM, Chris Lattner via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> wrote:</div><br></div></div><div><div><div class="h5"><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><blockquote type="cite"><div><br>On Dec 8, 2015, at 10:09 PM, Jacob Bandes-Storch <<a href="mailto:jtbandes@gmail.com" target="_blank">jtbandes@gmail.com</a>> wrote:</div><br><div>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></div></blockquote><div><br></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></div><div>-Chris</div><div><br></div><br><blockquote type="cite"><div><div class="gmail_quote"><div dir="ltr">On Tue, Dec 8, 2015 at 10:05 PM Chris Lattner <<a href="mailto:clattner@apple.com" target="_blank">clattner@apple.com</a>> wrote:<br></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"><br>> On Dec 8, 2015, at 9:53 PM, Jacob Bandes-Storch via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> wrote:<br>><br>> Enums are often used without associated values:<br>><br>> enum Attribute { case Title, Date }<br>> enum Style { case Dark, Light }<br>><br>> In such cases, it's very useful to be able to iterate over all possible values. But you have to do it manually:<br>><br>> extension Attribute {<br>> static var allValues: [Attribute] {<br>> return [.Title, .Date] // imagine this x100, and not autogenerated :(<br>> }<br>> }<br>><br>> 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><br>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><br>-Chris<br><br></blockquote></div></div></blockquote></div><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"></div></div><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=nE9rxSXA5G4kxsTVkgv43vFcOQoCM-2FU-2BigXPSqPoICJABVTHRKQmnAG1IVrL0l7bTTsDMUisvWbExjzI1-2BwvYS98-2B6n-2B2rpnw0ebuvD7v3P2BFpfxQXWkPuXsb8wTXmwGcEz-2FvDDvQfpsS-2FOeZR3z3-2FLFn5yzSig8Wu5B6dkMGC1Jaa59ceR7767VrSUQ5a2hUtJ67cMtLFlW1uhzamHofgxxEvAGdCz3dgtxKiDc0o-3D" alt="" width="1" height="1" border="0" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;min-height:1px!important;width:1px!important;border-width:0px!important;margin:0px!important;padding:0px!important"><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important"><span> </span></span><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">_______________________________________________</span><span class=""><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">swift-evolution mailing list</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><a href="mailto:swift-evolution@swift.org" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank">swift-evolution@swift.org</a><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span></div></blockquote></div><br></div></blockquote></div><br></div></div>