-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deriving collections of enum cases #114
Conversation
This is a big one, and i gather a lot of people want this. Hoping to see this taken on! |
I'm concerned that this proposal does not address the issue of differently-versioned cases in enums. For an enum like this public enum QoSClass {
@available(OSX 10.10, iOS 8.0, *)
case background
@available(OSX 10.10, iOS 8.0, *)
case utility
@available(OSX 10.10, iOS 8.0, *)
case `default`
@available(OSX 10.10, iOS 8.0, *)
case userInitiated
@available(OSX 10.10, iOS 8.0, *)
case userInteractive
case unspecified
} Should the derived conformance look like this? public static var allCases: [QoSClass] {
if #available(OSX 10.10, iOS 8.0, *) {
return [
QoSClass.background,
QoSClass.utility,
QoSClass.`default`,
QoSClass.userInitiated,
QoSClass.userInteractive,
QoSClass.unspecified,
]
} else {
return [ QoSClass.unspecified ]
}
} |
Moreover, do |
I'm closing out PRs for proposals that are out of scope for Swift 4 stage 1. When we open up the process to the point where this proposal can be in scope, please re-open the pull request. |
Is it possible this might fall into the scope of Swift 4 stage 2 now that priorities have been shuffled? |
I asked for some clarification about this on Twitter: https://twitter.com/jtbandes/status/834633693138350080 It sounds like it's potentially feasible to do with existing metadata. I've also seen it said that proposals that come with a full or partial implementation are more likely to be accepted 😉 So perhaps if I get some time I'll look at what it would take to add this. |
I'll bring it up with the full core team, but because this is purely additive, I don't think it meets the Swift 4 stage 2 criteria. |
Yeah, this is purely additive, and doesn't meet the Swift 4 stage 2 criteria. |
Can this pull request be re-opened for Swift 5? 🙏 |
This can be considered for Swift 5 as long as a potential proposal has an implementation. |
I have an implementation I would be willing to put up here. // @jtbandes |
Awesome, so glad to see the ball rolling on this! |
6044398
to
3eb50f0
Compare
Hi all, sorry for the long delay here. I've pushed a revised proposal with feedback incorporated from recent discussions. @DougGregor / @tkremenek, please advise if you see this as reviewable in its current form. @CodaFi's example implementation still stands, although it will need to be updated to match the naming choice in the final proposal, and to use associatedtype. |
Excellent. I'll rebase and update my branch this evening. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
* Proposal for deriving collections of enum cases * Make the derived implementation opt-in
swift-evolution discussion thread (other related threads are linked in the proposal).
Rendered Markdown.