Hello Swift Community,
The review of SE-0237 "Introduce Contiguous Collection Protocols" ran from November 16...27, 2018. The Core Team is returning this proposal for revision, with a few comments:
- The Core Team felt that the use of
inout
for the closure parameter ofwithUnsafeMutableBufferPointer(IfSupported)
was the best available option, and noted that the library could verify that theUnsafeMutableBufferPointer
itself wasn't directly modified by checking for the expected base address / count after the call. This limits the chance of confusion without resorting to shadowing or excessive overloading ofmutating
operations. - The two proposed protocols (
ContiguousCollection
andMutableContiguousCollection
) aren't used in any algorithms within the library. It is not clear that they are important enough to introduce as protocols into the Standard Library at this time. The Core Team would like to consider a revised proposal that does not introduce these protocols. - There are use cases for a
Sequence
equivalent to the proposedwithUnsafeMutableBufferPointerIfSupported
, such as initializing aString
from aSequence
ofUTF-8
code points that are (e.g.) stored in aData
. The Core Team would like to see this addition to theSequence
protocol, which would allowSequence
clients to optimize for the contiguously-stored case without requiring a new protocol, much as the proposal already allowsMutableCollection
clients to optimize for the contiguously-stored mutable case.
I'll initiate a new review thread for the revised proposal shortly.
Doug