<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 8, 2016, at 4:54 PM, Jordan Rose &lt;<a href="mailto:jordan_rose@apple.com" class="">jordan_rose@apple.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Dec 8, 2016, at 16:53, Ben Cohen &lt;<a href="mailto:ben_cohen@apple.com" class="">ben_cohen@apple.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Dec 8, 2016, at 4:35 PM, Jordan Rose via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Um, Sequence doesn’t have a subscript (or indexes). Sequences are single-pass. So if this is important, it needs to stay a Collection.</div><br class="Apple-interchange-newline"></div></blockquote></div><br class=""><div class="">Just because something fulfills one of the requirements of a Collection does not mean it should be one. It needs to tick all the boxes before its allowed to be elevated.</div><div class=""><br class=""></div><div class="">But it’s still allowed to have subscripts (UnsafePointer has subscripting but isn’t a collection) or be multi-pass (strides are multiples but are only sequences). That’s OK</div><div class=""><br class=""></div><div class="">In this case, yes it’s multi-pass, yes it has a subscript, but no it isn’t a collection because it doesn’t meet the requirements for slicing i.e. that indices of the slice be indices of the parent.</div><div class="">(relatedly… it appears this requirement is documented on the concrete Slice type rather than on Collection… which is a documentation bug we should fix).</div></div></div></blockquote></div><br class=""><div class="">Ah, right, thank you. Retracted.</div></div></div></blockquote></div><br class=""><div class=""><div class="">Let me restate, because I think Jordan's question was valid given my statement.</div><div class=""><br class=""></div><div class="">It would be *nice* for raw buffers to be Collection&lt;UInt8&gt; because they’re meant to be a replacement for code that is typically written for [UInt8], and anything you can do with an array that applies to raw buffers is covered by Collection&lt;UInt8&gt;.</div><div class=""><br class=""></div><div class="">However, I don’t expect the raw buffer to be used in a generic context except being passed to utilities that copy the bytes out. That will either be done by directly iterating over the collection or invoking some other API that could take a Sequence. The most important is probably Array.append(contentsOf:), which is moving over to Sequence. However, we would also need to change UnsafeRawBufferPointer(copyBytes:), NSData(replaceSubrange:), and whatever else I haven't thought of. That's a small disadvantage to this solution.</div><div class=""><br class=""></div><div class="">I'm also a little concerned that Sequence is immutable, so generic code has no way to copy bytes into the buffer.</div><div class=""><br class=""></div><div class="">My bigger concern is still that the range subscript’s inconsistent behavior may still lead to bugs in practice in nongeneric code.</div></div><div class=""><br class=""></div><div class="">-Andy</div></body></html>