Review of SE-0237: Introduce Contiguous Collection Protocols

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 of withUnsafeMutableBufferPointer(IfSupported) was the best available option, and noted that the library could verify that the UnsafeMutableBufferPointer 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 of mutating operations.
  • The two proposed protocols (ContiguousCollection and MutableContiguousCollection) 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 proposed withUnsafeMutableBufferPointerIfSupported, such as initializing a String from a Sequence of UTF-8 code points that are (e.g.) stored in a Data. The Core Team would like to see this addition to the Sequence protocol, which would allow Sequence clients to optimize for the contiguously-stored case without requiring a new protocol, much as the proposal already allows MutableCollection clients to optimize for the contiguously-stored mutable case.

I'll initiate a new review thread for the revised proposal shortly.

Doug