# Review of SE-0237: Introduce Contiguous Collection Protocols

**URL:** <https://forums.swift.org/t/review-of-se-0237-introduce-contiguous-collection-protocols/18069>\
**Category:** Proposal Reviews\
**Created:** [November 17, 2018, 12:15am UTC](https://forums.swift.org/t/review-of-se-0237-introduce-contiguous-collection-protocols/18069 "2018-11-17T00:15:44Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![Karl](https://avatars.discourse-cdn.com/v4/letter/k/34f0e0/32.png) [@Karl](https://forums.swift.org/u/Karl)\
**Post date:** [November 20, 2018, 6:53pm UTC](https://forums.swift.org/t/review-of-se-0237-introduce-contiguous-collection-protocols/18069/3 "2018-11-20T18:53:26Z")

</div>

**What is your evaluation of the proposal?**

+1. I think this is a valuable addition to the Collection protocol hierarchy. We've been talking about this protocol for years - I'm thrilled to see it finally come up for inclusion.

**Is the problem being addressed significant enough to warrant a change to Swift?**

Yes.

- There is a clear performance benefit to knowing that a Collection's elements are stored contiguously, especially if its implementation/iterator are otherwise opaque.
- Since C arrays are pointers, interop with C libraries becomes much easier.
- We have several types in the standard library, corelibs and associated projects which already use this pattern to provide a pointer to their storage. Library authors would like the option to write generic algorithms which care about _data_ rather than some specific semantics implied by a type (e.g. Array vs Data).

**Does this proposal fit well with the feel and direction of Swift?**

I think so. Although there are a couple of nits:

- If we can add a non-mutating `MutableCollection` conformance to UMBP (as suggested above), that would clearly be preferable to an `inout` parameter.
- I prefer the name `withUnsafeMutableBufferPointerIfContiguous`, because I think it more clearly implies that this is a kind of [type narrowing](https://forums.swift.org/t/proposal-type-narrowing/4433). That is to say, I think it makes it more obvious that rather than implementing the customisation point directly, you should conform to `MutableContiguousCollection`. The documentation should also mention this.

**If you have used other languages or libraries with a similar feature, how do you feel that this proposal compares to those?**

C++17 includes [contiguous iterators](https://isocpp.org/files/papers/n4132.html). As in this proposal, they imply random access.

**How much effort did you put into your review? A glance, a quick reading, or an in-depth study?**

Read proposal, participated in pitch discussion as well as several others.

---

_[View the full topic](https://forums.swift.org/t/review-of-se-0237-introduce-contiguous-collection-protocols/18069)._
