Skip to content

Propose a Disconnected type #3300

Open
FranzBusch wants to merge 7 commits into
swiftlang:mainfrom
FranzBusch:fb-disconnected
Open

Propose a Disconnected type #3300
FranzBusch wants to merge 7 commits into
swiftlang:mainfrom
FranzBusch:fb-disconnected

Conversation

@FranzBusch

Copy link
Copy Markdown
Member

No description provided.

@rjmccall rjmccall added LSG Contains topics under the domain of the Language Steering Group new proposal Adds a new proposal document labels May 26, 2026
@FranzBusch

Copy link
Copy Markdown
Member Author

@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 NotTheNHK left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* 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`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/...))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* 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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 And simply offering a Disconnected protocol wouldn't solve the problem, since you still need to implement it yourself, no different than today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

LSG Contains topics under the domain of the Language Steering Group new proposal Adds a new proposal document

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants