Propose a Disconnected type #3300
Conversation
74bb8ce to
2b9f68f
Compare
|
@rjmccall I opened a PR for the implementation swiftlang/swift#89597 and addressed all the pitch feedback so far. Could you add this to the LSGs proposal review inbox? |
NotTheNHK
left a comment
There was a problem hiding this comment.
I left a little bit of commentary. Overall, I think the proposal is going in the right direction. As much as I would prefer this to be handled directly by RBI, any potential solution would probably end up making things more complicated in the end.
| * Authors: [Franz Busch](https://github.com/FranzBusch) | ||
| * Review Manager: TBD | ||
| * Status: **Awaiting implementation** | ||
| * Implementation: [swiftlang/swift#NNNNN](https://github.com/swiftlang/swift/pull/NNNNN) |
There was a problem hiding this comment.
| * Implementation: [swiftlang/swift#NNNNN](https://github.com/swiftlang/swift/pull/NNNNN) | |
| * Implementation: https://github.com/swiftlang/swift/pull/89597 |
| } | ||
| ``` | ||
|
|
||
| One use-case might want to use the `UniqueDeque` to append non-`Sendable` |
There was a problem hiding this comment.
| One use-case might want to use the `UniqueDeque` to append non-`Sendable` | |
| One use-case might be to use `UniqueDeque` to append non-`Sendable` |
|
|
||
| This proposal introduces a `Disconnected` type that preserves the disconnected | ||
| property of a value through storage in data structures, allowing generic types | ||
| to safely transfer non-`Sendable` values across isolation regions without |
There was a problem hiding this comment.
I would consider changing the wording "across isolation regions" to "across isolation domains".
| values that must be in a disconnected region at function boundaries. | ||
|
|
||
| This proposal introduces a `Disconnected` type that preserves the disconnected | ||
| property of a value through storage in data structures, allowing generic types |
There was a problem hiding this comment.
I think we should expand this section a bit more and place less emphasis on generic types. While data structures are probably the most common use case, you can also use this type to store disconnected values in actors, for example. It's somewhat awkward ergonomically, but it can be useful at times.
|
|
||
| One use-case might want to use the `UniqueDeque` to append non-`Sendable` | ||
| disconnected values and when popping an element send it to a different isolation | ||
| region. |
There was a problem hiding this comment.
| region. | |
| domain. |
| this type for other important use-cases where users want to store non-`Sendable` | ||
| but **not disconnected** elements. | ||
|
|
||
| The fundamental limitation is that `sending` is a property of function |
There was a problem hiding this comment.
Nit: This sentence feels a bit awkward. I would suggest something like this instead:
The fundamental limitation is that sending is a property of function boundaries, not of types. Generic types such as UniqueDeque cannot conditionally control whether their stored elements should remain disconnected. Requiring append and popFirst to be sending would therefore only allow disconnected values to be stored in UniqueDeque.
| * Review Manager: TBD | ||
| * Status: **Awaiting implementation** | ||
| * Implementation: [swiftlang/swift#NNNNN](https://github.com/swiftlang/swift/pull/NNNNN) | ||
| * Review: ([pitch](https://forums.swift.org/...)) |
There was a problem hiding this comment.
| * Review: ([pitch](https://forums.swift.org/...)) | |
| * Review: ([pitch](https://forums.swift.org/t/pitch-disconnected-type-for-modeling-disconnected-values/86815)) |
|
|
||
| Different names such as `Nonisolated` and `DisconnectedRegion` were considered; | ||
| however, the name `Disconnected` felt the most fitting. Furthermore, the concept | ||
| of a disconnected region was introduced in previous proposals. |
There was a problem hiding this comment.
Nit: Perhaps we should emphasize even more that the term "disconnected" is commonly used in RBI.
|
|
||
| ### Making `Disconnected` a protocol | ||
|
|
||
| A `Disconnected` protocol could be applied to existing types. However, this |
There was a problem hiding this comment.
👍 And simply offering a Disconnected protocol wouldn't solve the problem, since you still need to implement it yourself, no different than today.
No description provided.