[swift-evolution] [swift-evolution-announce] [Review] SE-0194: Derived Collection of Enum Cases
matthew at anandabits.com
Wed Jan 10 14:10:42 CST 2018
> What is your evaluation of the proposal?
+1. I have written plenty of enums with the `allValues` property. It will be nice to have this synthesized.
I do think a small clarification or revision is warranted, however. I would like to see a rationale stated for choosing the `Collection` requirement rather than `Sequence` or `RandomAccessCollection`. The `Sequence` alternative has been discussed in some depth on the list and this discussion is not represented in the alternatives section.
I bring up `RandomAccessCollection` as an alternative worth discussing because I strongly believe the proposal should require the compiler synthesized `ValueCollection` types to also conform to `RandomAccessCollection` and further have `Int` indices. One of the leading motivating use cases for this proposal is in implementing data sources which requires both `Int` indices and also carries an expectation of a constant time subscript operation.
Placing a stronger requirement on the compiler-synthesized implementation than we do on manual conformances is somewhat subtle so we should at least consider whether such requirements are acceptable for all conformances or not and address that in the proposal. I don’t know of any use cases for a manual conformance where meeting the stricter requirements would be problematic. On the other hand, requiring an `Int` index in particular seems like it is probably too strict.
I support the proposal regardless of the decision but believe additional discussion and documentation of the alternative constraints would be healthy.
> Is the problem being addressed significant enough to warrant a change to Swift?
Absolutely. This is a very common source of boilerplate that is prone to break as code changes.
> Does this proposal fit well with the feel and direction of Swift?
> If you have used other languages or libraries with a similar feature, how do you feel that this proposal compares to those?
> How much effort did you put into your review? A glance, a quick reading, or an in-depth study?
In-depth study and participation in prior threads.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution