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-10653] exhaustive capture lists #53053

Open
weissi opened this issue May 10, 2019 · 2 comments
Open

[SR-10653] exhaustive capture lists #53053

weissi opened this issue May 10, 2019 · 2 comments
Labels
compiler The Swift compiler in itself feature A feature request or implementation swift evolution proposal needed Flag → feature: A feature that warrants a Swift evolution proposal

Comments

@weissi
Copy link
Member

weissi commented May 10, 2019

Previous ID SR-10653
Radar rdar://problem/52529022
Original Reporter @weissi
Type New Feature
Additional Detail from JIRA
Votes 1
Component/s Compiler
Labels New Feature, LanguageFeatureRequest
Assignee None
Priority Medium

md5: 655268a5880dcf0a0aaaf3a9b2886422

Issue Description:

Swift really ought to have a way to specify exhaustive capture list. I really frequently want to specify an exhaustive list of captures, often empty.

Currently what I usually do (as an approximation) is to convert the closure to a static func with the 'captures' as parameters so I have reasonable confidence. Then I convert it back to a closure but this may break at any point in time.

Strawman syntax:

struct Foo {
   var bar: String = ""
   
   mutating func buz() {
       DispatchQueue(label: "foo").async { ![] in
           print("\(self.bar)") // compile error
       }
}

What the strawman syntax doesn't provide at the moment is a way to capture by reference (which is usually done for {{var}}s).

@belkadan
Copy link
Contributor

This would have to go through Swift Evolution.

@weissi
Copy link
Member Author

weissi commented Jul 2, 2019

@swift-ci create

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added swift evolution proposal needed Flag → feature: A feature that warrants a Swift evolution proposal and removed new feature labels Nov 11, 2022
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 feature A feature request or implementation swift evolution proposal needed Flag → feature: A feature that warrants a Swift evolution proposal
Projects
None yet
Development

No branches or pull requests

3 participants