[swift-evolution] [Pitch] Normalize Slice Types for Unsafe Buffers

Dave Abrahams dabrahams at apple.com
Fri Dec 9 12:22:58 CST 2016


on Thu Dec 08 2016, Jordan Rose <jordan_rose-AT-apple.com> wrote:

>> On Dec 8, 2016, at 16:22, Andrew Trick via swift-evolution 
>> <swift-evolution at swift.org> wrote:
>> 
>> In practice, it needs to be able to interoperate with [UInt8] 
>> and be interchangeable in the same
> generic context.
>> 
>> e.g. `byteBuffer += rawBuffer[payloadIndex..<endIndex]` is 
>> typical.
>> 
>> I think Sequence is sufficient for that purpose.
>
> Um, Sequence doesn’t have a subscript (or indexes). Sequences 
> are single-pass. So if this is
> important, it needs to stay a Collection.

Yes.  But I don't see why the raw buffer should be a collection in 
the first place.  Why not

  byteBuffer += rawBuffer.bytes[payloadIndex..<endIndex]

?

-- 
-Dave


More information about the swift-evolution mailing list