Skip to content

Commit 0dc7d62

Browse files
committed
Flesh out the disconnected types future direction.
1 parent d3329d7 commit 0dc7d62

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

proposals/NNNN-transferring-parameters-and-results.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,20 @@ explicitly) `consuming`.
334334

335335
## Future directions
336336

337-
### `disconnected` types
338-
339-
TODO
337+
### `Disconnected` types
338+
339+
`transferring` requires parameter and result values to be in a disconnected
340+
region at the function boundary, but there is no way to preserve that a value
341+
is in a disconnected region through stored properties, collections, function
342+
calls, etc. To preserve that a value is in a disconnected region through the
343+
type system, we could introduce a `Disconnected` type into the Concurrency
344+
library. The `Disconnected` type would suppress copying via `~Copyable`, it
345+
would conform to `Sendable`, constructing a `Disconnected` instance would
346+
require the value it wraps to be in a disconnected region, and a value of type
347+
`Disconnected` can never be merged into another isolation region.
348+
349+
This would enable important patterns that take a `transferring T` parameter,
350+
store the value in a collection of `Disconnected<T>`, and later remove values
351+
from the collection and return them as `transferring T` results. This would
352+
allow some `AsyncSequence` types to return non-`Sendable` buffered elements as
353+
`transferring` without resorting to unsafe opt-outs in the implementation.

0 commit comments

Comments
 (0)