Skip to content
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

[SR-3050] enum cases should be enumerable #45640

Closed
swift-ci opened this issue Oct 26, 2016 · 4 comments
Closed

[SR-3050] enum cases should be enumerable #45640

swift-ci opened this issue Oct 26, 2016 · 4 comments
Labels
compiler The Swift compiler in itself improvement reflection

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-3050
Radar rdar://problem/28952398
Original Reporter russ (JIRA User)
Type Improvement
Additional Detail from JIRA
Votes 3
Component/s Compiler
Labels Improvement, Reflection
Assignee None
Priority Medium

md5: abaa7fad97302a7f478a955d30d3dd52

relates to:

  • SR-30 Enumerations could have a "allValues" property

Issue Description:

Swift should be able to enumerate the cases of an enum. The machinery appears to be there, the case mirrors just need to be returned as children from the metatype Mirror. (Case mirrors already allow you to enumerate associated values as children.)

@belkadan
Copy link
Contributor

I'm not sure this makes any sense for enums with associated values.

@CodaFi
Copy link
Member

CodaFi commented Oct 27, 2016

Even in the case of a "simple" enum, this is still subject to the availability concerns I have in the case the compiler automagically derives an {code:java}allCases

@swift-ci
Copy link
Collaborator Author

Comment by Raphael (JIRA)

@belkadan As long as the parameter space is finite (e.g. other enums without associated values), the semantics are clear (even though the list may become long). For infinite parameter spaces, lazy enumeration would still be possible in principle (unless we have floats), but arguably not very useful. So yes, if the compiler can not determine the full list (quickly?), this makes no sense.

Maybe the way to go is a protocol. We'd still have to implement it for ever enum, but at least there's be standard way to provide and access all values, if possible.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@tshortli
Copy link
Contributor

This was SE-0194.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler The Swift compiler in itself improvement reflection
Projects
None yet
Development

No branches or pull requests

4 participants