Swift: enum cases should be callable as functions
| Originator: | rix.rob | ||
| Number: | rdar://20906616 | Date Originated: | 11-May-2015 06:35 PM |
| Status: | Open | Resolved: | |
| Product: | Developer Tools | Product Version: | Xcode-beta (6E14) |
| Classification: | Enhancement | Reproducible: | Always |
Summary:
I thought I’d filed this but maybe not so here goes.
Given some type P and an enum like so:
enum E {
case C(P)
}
E.C should be a first-class function of type P -> E, by which I specifically mean that I should be able to pass it as an argument to map.
This should also be the case for cases without values, in which case it should introduce two symbols:
- E.C, a first-class function of type () -> E, as above
- E.C, a first-class value of type E, as it currently is
Presumably it should prefer the latter.
I’d be willing to accept omitting parameterless cases from receiving first class functions, but every time Swift’s implementation special cases something, I die a little inside.
Steps to Reproduce:
N/A
Expected Results:
N/A
Actual Results:
N/A
Regression:
N/A
Notes:
N/A
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!