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

Hooman Mehr hooman at mac.com
Fri Dec 2 13:16:40 CST 2016

+1 on the third option it being clearly the best way to model pointers. Making the index strideable makes its use in index computations easy. It takes a bit care to make it work as conveniently for UnsafeBufferPointer where the stride will need to be special.

> On Dec 1, 2016, at 11:33 PM, Nate Cook via swift-evolution <swift-evolution at swift.org> wrote:
> 3) Make all buffer pointers their own slices but use a different index type. If the indices were just wrapped pointers, that would handle the index sharing without needing an additional property on the buffer. We could also maintain integer-based stridable conformance (which greatly simplifies index arithmetic), since the indices would just offset by a byte for raw buffers or a stride for typed buffers.
> The first option would certainly be the smallest change; the third seems like it would do the most good, for the reasons Dave laid out. I've tried the third option out here for raw buffers:
> 	https://github.com/apple/swift/compare/master...natecook1000:nc-buffer-indices <https://github.com/apple/swift/compare/master...natecook1000:nc-buffer-indices>
> Thanks!
> Nate

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20161202/095ba70e/attachment.html>

More information about the swift-evolution mailing list