[swift-evolution] List of all Enum values (for simple enums)
Jacob Bandes-Storch
jtbandes at gmail.com
Wed Dec 9 19:24:21 CST 2015
On Wed, Dec 9, 2015 at 5:05 PM, Chris Lattner <clattner at apple.com> wrote:
>
> On Dec 9, 2015, at 10:19 AM, David Waite <david at alkaline-solutions.com>
> wrote:
>
> There are a number of possible proposals for enhancements I see off the
> bat for “basic" enums (without associated data):
>
> 1. A generated implementation of SequenceType based on declaration order
> 2. A second interface or extension to the enum type could supply static
> max and min properties when the RawValue is Comparable
> 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.
>
>
> Another design point to consider: instead of making *every* enum generate
> the “allValues” capability, it might make sense to restrict this
> synthesization to enums that opt into it by conforming to a protocol.
> Intentionally not the right protocol name, but perhaps:
>
> enum X { A, B } // not enumerable.
> enum X : Enumerable { A, B } // has allValues and other stuff
> automatically generated.
>
> -Chris
>
And I suppose it would have to be possible to add this conformance to a
pre-existing type? You'd want to be able to do "extension NSTextAlignment
: Enumerable {}". But I'm not sure if it would work well to generate this
on-demand; might work better to do it at interface-generation time, along
with OptionSetType conformances, etc.
Jacob
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151209/fe980fea/attachment.html>
More information about the swift-evolution
mailing list