|
1 | 1 | # OutputSpan: delegate initialization of contiguous memory
|
2 | 2 |
|
3 |
| -* Proposal: TBD |
| 3 | +* Proposal: [SE-0485](0485-outputspan.md) |
4 | 4 | * Author: [Guillaume Lessard](https://github.com/glessard)
|
5 |
| -* Review Manager: TBD |
6 |
| -* Status: **Pitch** |
| 5 | +* Review Manager: [Doug Gregor](https://github.com/DougGregor) |
| 6 | +* Status: **Active Review (May 20...June 3, 2025)** |
7 | 7 | * Roadmap: [BufferView Roadmap](https://forums.swift.org/t/66211)
|
8 | 8 | * Implementation: "Future" target of [swift-collections](https://github.com/apple/swift-collections/tree/future)
|
9 | 9 | * Review: [Pitch](https://forums.swift.org/)
|
@@ -58,7 +58,7 @@ In addition to the new types, we propose adding new API for some standard librar
|
58 | 58 |
|
59 | 59 | `OutputSpan` allows delegating the initialization of a type's memory, by providing access to an exclusively-borrowed view of a range of contiguous memory. `OutputSpan`'s contiguous memory always consists of a prefix of initialized memory, followed by a suffix of uninitialized memory. `OutputSpan`'s operations manage the initialization state in order to preserve that invariant. The common usage pattern we expect to see for `OutputSpan` consists of passing it as an `inout` parameter to a function, allowing the function to produce an output by writing into a previously uninitialized region.
|
60 | 60 |
|
61 |
| -Like `MutableSpan`, `OutputSpan` relies on two guarantees: (a) that it has exclusive access to the range of memory it represents, and (b) that the memory locations it represents will remain valid for the duration of the access. These guarantee data race safety and temporal safety. `OutputSpan` performs bounds-checking on every access to preserve spatial safety. `OutputSpan` manages the initialization state of the memory in represents on behalf of the memory's owner. |
| 61 | +Like `MutableSpan`, `OutputSpan` relies on two guarantees: (a) that it has exclusive access to the range of memory it represents, and (b) that the memory locations it represents will remain valid for the duration of the access. These guarantee data race safety and lifetime safety. `OutputSpan` performs bounds-checking on every access to preserve bounds safety. `OutputSpan` manages the initialization state of the memory in represents on behalf of the memory's owner. |
62 | 62 |
|
63 | 63 | #### OutputRawSpan
|
64 | 64 |
|
@@ -936,7 +936,7 @@ The additions described in this proposal require a new version of the Swift stan
|
936 | 936 |
|
937 | 937 | `OutputSpan` lays the groundwork for new, generalized `Container` protocols that will expand upon and succeed the `Collection` hierarchy while allowing non-copyability and non-escapability to be applied to both containers and elements. We hope to find method and property names that will be generally applicable. The origin of the `append(contentsOf:)` method we are expanding upon is the `RangeReplaceableCollection` protocol, which always represents copyable and escapable collections with copyable and escapable elements. The definition is as follows: `mutating func append<S: Sequence>(contentsOf newElements: __owned S)`. This supports copying elements from the source, while also destroying the source if we happen to hold its only copy. This is obviously not sufficient if the elements are non-copyable, or if we only have access to a borrow of the source.
|
938 | 938 |
|
939 |
| -When the elements are non-copyable, we must append elements that are removed from the source. Afterwards, there are two possible dispositions of the source: destruction (`consuming`,) where the source can no longer be used, or mutation (`inout`,) where the source has been emptied but is still usable. |
| 939 | +When the elements are non-copyable, we must append elements that are removed from the source. Afterwards, there are two possible dispositions of the source: destruction (`consuming`), where the source can no longer be used, or mutation (`inout`), where the source has been emptied but is still usable. |
940 | 940 |
|
941 | 941 | When the elements are copyable, we can simply copy the elements from the source. Afterwards, there are two possible dispositions of the source: releasing a borrowed source, or `consuming`. The latter is approximately the same behaviour as `RangeReplaceableCollection`'s `append()` function shown above.
|
942 | 942 |
|
@@ -985,7 +985,7 @@ A use case similar to appending is insertions. Appending is simply inserting at
|
985 | 985 |
|
986 | 986 | #### Generalized removals
|
987 | 987 |
|
988 |
| -Similarly to generalized insertions (i.e. not from the end,) we can think about removals of one or more elements starting at a given position. This also requires adding indexing. We expect to add generalized removals along with insertions if `OutputSpan` is accepted. |
| 988 | +Similarly to generalized insertions (i.e. not from the end), we can think about removals of one or more elements starting at a given position. This also requires adding indexing. We expect to add generalized removals along with insertions if `OutputSpan` is accepted. |
989 | 989 |
|
990 | 990 | #### Variations on `Array.append(addingCapacity:initializingWith:)`
|
991 | 991 |
|
|
0 commit comments