-
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
closure isolation #2322
base: main
Are you sure you want to change the base?
closure isolation #2322
Conversation
e2315b0
to
ef0d6b2
Compare
ef0d6b2
to
16e9bf0
Compare
proposals/nnnn-closure-isolation.md
Outdated
```swift | ||
actor A { | ||
func isolate() { | ||
Task { [isolated self] in |
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.
Does this imply the following scenarios?
func isolate(on otherActor: some AnyActor) {
Task { [isolated otherActor] in
// Valid
}
}
func isolate(on otherActor: some AnyActor) {
Task { [isolated otherActor] in
self.bool.toggle() // Fails compilation because `otherActor` isolation does not match `self`'s isolation
}
}
protocol Toggleable {
func toggle()
}
func isolate(on otherActor: some AnyActor & Toggleable) {
Task { [isolated otherActor] in
otherActor.toggle() // Successful, because this Task is isolated to `otherActor`'s isolation
}
}
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.
(Let me preface by saying that this proposal isn't fully baked yet, hence not having been pitched or added anyone to the PR yet.)
The first example, it is unclear to me what is "valid" given that the body of the closure does not do anything? But the syntax for the isolation capture is valid, and the capture will be isolated to otherActor
.
The second example correct will fail.
The third example yes correct as well.
8b0dde7
to
54c1550
Compare
54c1550
to
7e4d540
Compare
f926a22
to
0fb068e
Compare
…ses when used with parameters
…atibility" section
Some typos and a few small wording changes
|
||
class New { | ||
public init(@inheritsIsolation operation: () async) | ||
} |
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.
These two examples both have a tiny typo in them. They are missing a -> Void
.
No description provided.