<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 Jan 27, 2017, at 7:36 PM, Zach Waldowski 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="">


<title class=""></title>

<div class=""><div style="font-family:Arial;" class="">I like the sound of it so far, but my first major thought is that isn't it modeling a "has-a" relationship instead of an "is-a"? The buffer methods indicate that the data type *can* be represented as a buffer for the duration of the method call, but may not necessarily be before or after. Such a semantic distinction would also allow Data and DispatchData, as well as other theoretical data structures like a Deque (I think?) to participate.</div></div></div></blockquote><div><br class=""></div><div>I copied those parts of the documentation from Array. Unlike ArraySlice and ContiguousArray, due to NSArray compatibility, continuous storage for Array isn’t prepared until needed. I didn’t mean to imply that the relationship isn’t IS-A. Although now I don’t see any reason to ban ephemeral storage, the conforming type should act as if its element state is consistent between calls. (A conforming type that generates a new random block before each call, even ignoring previous mutations, isn’t very useful.)</div><div><br class=""></div><div><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">—&nbsp;</div><div class="">Daryle Walker<br class="">Mac, Internet, and Video Game Junkie<br class="">darylew AT mac DOT com&nbsp;</div><div class=""><br class=""></div></div></div></div><blockquote type="cite" class=""><div class=""><div class="">
<div id="sig40804545" class=""><div class="signature"><span class="font" style="font-family:arial, sans-serif, sans-serif">Cheers!</span><span class="font" style="font-family:arial, sans-serif, sans-serif"></span><br class=""></div>
<div class="signature"><span class="font" style="font-family:arial, sans-serif, sans-serif">&nbsp; Zachary Waldowski</span><span class="font" style="font-family:arial, sans-serif, sans-serif"></span><br class=""></div>
<div class="signature"><span class="font" style="font-family:arial, sans-serif, sans-serif">&nbsp;&nbsp;</span><a href="mailto:zach@waldowski.me" class=""><span class="font" style="font-family:arial, sans-serif, sans-serif">zach@waldowski.me</span></a><br class=""></div>
</div>
<div class=""><br class=""></div>
<div class=""><br class=""></div>
<div class="">On Fri, Jan 27, 2017, at 06:40 PM, Daryle Walker via swift-evolution wrote:<br class=""></div>
<blockquote type="cite" class=""><div class="">I was perusing the library for array ideas, and noticed that several types had methods in common, but without a grouping protocol. Shouldn’t that be fixed?<br class=""></div>
<div class=""><br class=""></div>
<div class="">(Oh, if multiple protocols have an associated-type with the same name, is that a problem? Is it a problem if they resolve differently for each protocol attached to a given type? I’m asking because these protocols reuse Sequence’s Element for their own purpose.)<br class=""></div>
<div class=""><br class=""></div>
<div class=""><br class=""></div>
<div class=""><h1 style="margin-right:0px;margin-bottom:10px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;-webkit-font-smoothing:antialiased;position:relative;font-size:28px;font-family:Helvetica, arial, sans-serif;background-color:rgb(255, 255, 255);margin-top:0px !important;" class="">Formal Protocol for Contiguous Storage Visitation<br class=""></h1><ul style="margin-top:15px;margin-right:0px;margin-bottom:15px;margin-left:0px;padding-left:30px;font-family:Helvetica, arial, sans-serif;font-size:14px;background-color:rgb(255, 255, 255);" class=""><li style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;" class="">Proposal:&nbsp;<a style="color:rgb(65, 131, 196);margin-top:0px;" class="">SE-NNNN</a><br class=""></li><li style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;" class="">Authors:&nbsp;<a href="https://github.com/CTMacUser" style="color:rgb(65, 131, 196);margin-top:0px;" class="">Daryle Walker</a><br class=""></li><li style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;" class="">Review Manager: TBD<br class=""></li><li style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;" class="">Status:&nbsp;<b class="">Awaiting review</b><br class=""></li></ul><p style="margin: 15px 0px;" class=""><span class="highlight" style="background-color:rgb(255, 255, 255)"><span class="font" style="font-family:Helvetica, arial, sans-serif"><span class="size" style="font-size:14px"><i class="">During the review process, add the following fields as needed:</i></span></span></span><br class=""></p><ul style="margin-top:15px;margin-right:0px;margin-bottom:15px;margin-left:0px;padding-left:30px;font-family:Helvetica, arial, sans-serif;font-size:14px;background-color:rgb(255, 255, 255);" class=""><li style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;" class="">Decision Notes:&nbsp;<a href="https://lists.swift.org/pipermail/swift-evolution/" style="color:rgb(65, 131, 196);margin-top:0px;" class="">Rationale</a>,&nbsp;<a href="https://lists.swift.org/pipermail/swift-evolution/" style="color:rgb(65, 131, 196);" class="">Additional Commentary</a><br class=""></li><li style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;" class="">Bugs:&nbsp;<a href="https://bugs.swift.org/browse/SR-NNNN" style="color:rgb(65, 131, 196);margin-top:0px;" class="">SR-NNNN</a>,&nbsp;<a href="https://bugs.swift.org/browse/SR-MMMM" style="color:rgb(65, 131, 196);" class="">SR-MMMM</a><br class=""></li><li style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;" class="">Previous Revision:&nbsp;<a href="https://github.com/apple/swift-evolution/blob/...commit-ID.../proposals/NNNN-filename.md" style="color:rgb(65, 131, 196);margin-top:0px;" class="">1</a><br class=""></li><li style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;" class="">Previous Proposal:&nbsp;<a style="color:rgb(65, 131, 196);margin-top:0px;" class="">SE-XXXX</a><br class=""></li></ul><h2 style="margin-top:20px;margin-right:0px;margin-bottom:10px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;-webkit-font-smoothing:antialiased;position:relative;font-size:24px;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(204, 204, 204);font-family:Helvetica, arial, sans-serif;background-color:rgb(255, 255, 255);" class="">Introduction<br class=""></h2><p style="margin: 15px 0px;" class=""><span class="highlight" style="background-color:rgb(255, 255, 255)"><span class="font" style="font-family:Helvetica, arial, sans-serif"><span class="size" style="font-size:14px">The standard library types&nbsp;<code style="margin-top:0px;margin-right:2px;margin-bottom:0px;margin-left:2px;padding-top:0px;padding-right:5px;padding-bottom:0px;padding-left:5px;white-space:nowrap;border-top-width:1px;border-right-width:1px;border-bottom-width:1px;border-left-width:1px;border-top-style:solid;border-right-style:solid;border-bottom-style:solid;border-left-style:solid;border-top-color:rgb(234, 234, 234);border-right-color:rgb(234, 234, 234);border-bottom-color:rgb(234, 234, 234);border-left-color:rgb(234, 234, 234);border-image-source:initial;border-image-slice:initial;border-image-width:initial;border-image-outset:initial;border-image-repeat:initial;background-color:rgb(248, 248, 248);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;" class="">Array</code>,&nbsp;<code style="margin-top:0px;margin-right:2px;margin-bottom:0px;margin-left:2px;padding-top:0px;padding-right:5px;padding-bottom:0px;padding-left:5px;white-space:nowrap;border-top-width:1px;border-right-width:1px;border-bottom-width:1px;border-left-width:1px;border-top-style:solid;border-right-style:solid;border-bottom-style:solid;border-left-style:solid;border-top-color:rgb(234, 234, 234);border-right-color:rgb(234, 234, 234);border-bottom-color:rgb(234, 234, 234);border-left-color:rgb(234, 234, 234);border-image-source:initial;border-image-slice:initial;border-image-width:initial;border-image-outset:initial;border-image-repeat:initial;background-color:rgb(248, 248, 248);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;" class="">ArraySlice</code>, and&nbsp;<code style="margin-top:0px;margin-right:2px;margin-bottom:0px;margin-left:2px;padding-top:0px;padding-right:5px;padding-bottom:0px;padding-left:5px;white-space:nowrap;border-top-width:1px;border-right-width:1px;border-bottom-width:1px;border-left-width:1px;border-top-style:solid;border-right-style:solid;border-bottom-style:solid;border-left-style:solid;border-top-color:rgb(234, 234, 234);border-right-color:rgb(234, 234, 234);border-bottom-color:rgb(234, 234, 234);border-left-color:rgb(234, 234, 234);border-image-source:initial;border-image-slice:initial;border-image-width:initial;border-image-outset:initial;border-image-repeat:initial;background-color:rgb(248, 248, 248);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;" class="">ContiguousArray</code>&nbsp;have an interface for visiting their elements as a contiguous block of memory (arranging said elements to that configuration first if necessary). These methods are all the same, but not under a common protocol (i.e. seeming to match by "coincidence").</span></span></span><br class=""></p><p style="margin: 15px 0px;" class=""><span class="highlight" style="background-color:rgb(255, 255, 255)"><span class="font" style="font-family:Helvetica, arial, sans-serif"><span class="size" style="font-size:14px">This proposal seeks to correct that with two new protocols that these types will implement.</span></span></span><br class=""></p><p style="margin: 15px 0px;" class=""><span class="highlight" style="background-color:rgb(255, 255, 255)"><span class="font" style="font-family:Helvetica, arial, sans-serif"><span class="size" style="font-size:14px">Swift-evolution thread:&nbsp;<a href="https://lists.swift.org/pipermail/swift-evolution/" style="color:rgb(65, 131, 196);" class="">Discussion thread topic for that proposal</a></span></span></span><br class=""></p><h2 style="margin-top:20px;margin-right:0px;margin-bottom:10px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;-webkit-font-smoothing:antialiased;position:relative;font-size:24px;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(204, 204, 204);font-family:Helvetica, arial, sans-serif;background-color:rgb(255, 255, 255);" class="">Motivation<br class=""></h2><p style="margin: 15px 0px;" class=""><span class="highlight" style="background-color:rgb(255, 255, 255)"><span class="font" style="font-family:Helvetica, arial, sans-serif"><span class="size" style="font-size:14px">Just adding these protocols for consistency is relatively minor, but they may be used for other types. Particularly, they would be needed if fixed-sized arrays are added to the language.</span></span></span><br class=""></p><h2 style="margin-top:20px;margin-right:0px;margin-bottom:10px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;-webkit-font-smoothing:antialiased;position:relative;font-size:24px;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(204, 204, 204);font-family:Helvetica, arial, sans-serif;background-color:rgb(255, 255, 255);" class="">Proposed solution<br class=""></h2><p style="margin: 15px 0px;" class=""><span class="highlight" style="background-color:rgb(255, 255, 255)"><span class="font" style="font-family:Helvetica, arial, sans-serif"><span class="size" style="font-size:14px">The library array types will follow the&nbsp;<code style="margin-top:0px;margin-right:2px;margin-bottom:0px;margin-left:2px;padding-top:0px;padding-right:5px;padding-bottom:0px;padding-left:5px;white-space:nowrap;border-top-width:1px;border-right-width:1px;border-bottom-width:1px;border-left-width:1px;border-top-style:solid;border-right-style:solid;border-bottom-style:solid;border-left-style:solid;border-top-color:rgb(234, 234, 234);border-right-color:rgb(234, 234, 234);border-bottom-color:rgb(234, 234, 234);border-left-color:rgb(234, 234, 234);border-image-source:initial;border-image-slice:initial;border-image-width:initial;border-image-outset:initial;border-image-repeat:initial;background-color:rgb(248, 248, 248);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;" class="">MutableContiguousBlock</code>protocol, which inherits from the&nbsp;<code style="margin-top:0px;margin-right:2px;margin-bottom:0px;margin-left:2px;padding-top:0px;padding-right:5px;padding-bottom:0px;padding-left:5px;white-space:nowrap;border-top-width:1px;border-right-width:1px;border-bottom-width:1px;border-left-width:1px;border-top-style:solid;border-right-style:solid;border-bottom-style:solid;border-left-style:solid;border-top-color:rgb(234, 234, 234);border-right-color:rgb(234, 234, 234);border-bottom-color:rgb(234, 234, 234);border-left-color:rgb(234, 234, 234);border-image-source:initial;border-image-slice:initial;border-image-width:initial;border-image-outset:initial;border-image-repeat:initial;background-color:rgb(248, 248, 248);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;" class="">ContiguousBlock</code>&nbsp;protocol.</span></span></span><br class=""></p><div style="font-family:Helvetica, arial, sans-serif;font-size:14px;background-color:rgb(255, 255, 255);" class=""><pre style="margin-top:15px;margin-bottom:15px;background-color:rgb(248, 248, 248);border-top-width:1px;border-right-width:1px;border-bottom-width:1px;border-left-width:1px;border-top-style:solid;border-right-style:solid;border-bottom-style:solid;border-left-style:solid;border-top-color:rgb(204, 204, 204);border-right-color:rgb(204, 204, 204);border-bottom-color:rgb(204, 204, 204);border-left-color:rgb(204, 204, 204);border-image-source:initial;border-image-slice:initial;border-image-width:initial;border-image-outset:initial;border-image-repeat:initial;font-size:13px;line-height:19px;overflow-x:auto;overflow-y:auto;padding-top:6px;padding-right:10px;padding-bottom:6px;padding-left:10px;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;" class=""><code style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;border-top-width:initial;border-right-width:initial;border-bottom-width:initial;border-left-width:initial;border-top-style:none;border-right-style:none;border-bottom-style:none;border-left-style:none;border-top-color:initial;border-right-color:initial;border-bottom-color:initial;border-left-color:initial;border-image-source:initial;border-image-slice:initial;border-image-width:initial;border-image-outset:initial;border-image-repeat:initial;background-color:transparent;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;" class="">extension Array: MutableContiguousBlock {
}

extension ArraySlice: MutableContiguousBlock {
}

extension ContiguousArray: MutableContiguousBlock {
}</code><br class=""></pre></div><p style="margin: 15px 0px;" class=""><span class="highlight" style="background-color:rgb(255, 255, 255)"><span class="font" style="font-family:Helvetica, arial, sans-serif"><span class="size" style="font-size:14px">For example, a repackaging of the library's example code:</span></span></span><br class=""></p><div style="font-family:Helvetica, arial, sans-serif;font-size:14px;background-color:rgb(255, 255, 255);" class=""><pre style="margin-top:15px;margin-bottom:15px;background-color:rgb(248, 248, 248);border-top-width:1px;border-right-width:1px;border-bottom-width:1px;border-left-width:1px;border-top-style:solid;border-right-style:solid;border-bottom-style:solid;border-left-style:solid;border-top-color:rgb(204, 204, 204);border-right-color:rgb(204, 204, 204);border-bottom-color:rgb(204, 204, 204);border-left-color:rgb(204, 204, 204);border-image-source:initial;border-image-slice:initial;border-image-width:initial;border-image-outset:initial;border-image-repeat:initial;font-size:13px;line-height:19px;overflow-x:auto;overflow-y:auto;padding-top:6px;padding-right:10px;padding-bottom:6px;padding-left:10px;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;" class=""><code style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;border-top-width:initial;border-right-width:initial;border-bottom-width:initial;border-left-width:initial;border-top-style:none;border-right-style:none;border-bottom-style:none;border-left-style:none;border-top-color:initial;border-right-color:initial;border-bottom-color:initial;border-left-color:initial;border-image-source:initial;border-image-slice:initial;border-image-width:initial;border-image-outset:initial;border-image-repeat:initial;background-color:transparent;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;" class="">func change&lt;T: MutableContiguousBlock&gt;(object: inout T) -&gt; T.Element where T.Element: Integer {
    let sum = object.withUnsafeBufferPointer { (buffer) -&gt; T.Element in
        var result: T.Element = 0
        for i in stride(from: buffer.startIndex, to: buffer.endIndex, by: 2) {
            result += buffer[i]
        }
        return result
    }
    object.withUnsafeMutableBufferPointer { buffer in
        for j in stride(from: buffer.startIndex, to: buffer.endIndex - 1, by: 2) {
            swap(&amp;buffer[j], &amp;buffer[j + 1])
        }
    }
    return sum
}

var numbers = [1, 2, 3, 4, 5]
print(change(object: &amp;numbers))  // 9
print(numbers)                   // [2, 1, 4, 3, 5]</code><br class=""></pre></div>
<h2 style="margin-top:20px;margin-right:0px;margin-bottom:10px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;-webkit-font-smoothing:antialiased;position:relative;font-size:24px;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(204, 204, 204);font-family:Helvetica, arial, sans-serif;background-color:rgb(255, 255, 255);" class="">Detailed design<br class=""></h2><div style="font-family:Helvetica, arial, sans-serif;font-size:14px;background-color:rgb(255, 255, 255);" class=""><pre style="margin-top:15px;margin-bottom:15px;background-color:rgb(248, 248, 248);border-top-width:1px;border-right-width:1px;border-bottom-width:1px;border-left-width:1px;border-top-style:solid;border-right-style:solid;border-bottom-style:solid;border-left-style:solid;border-top-color:rgb(204, 204, 204);border-right-color:rgb(204, 204, 204);border-bottom-color:rgb(204, 204, 204);border-left-color:rgb(204, 204, 204);border-image-source:initial;border-image-slice:initial;border-image-width:initial;border-image-outset:initial;border-image-repeat:initial;font-size:13px;line-height:19px;overflow-x:auto;overflow-y:auto;padding-top:6px;padding-right:10px;padding-bottom:6px;padding-left:10px;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;" class=""><code style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;border-top-width:initial;border-right-width:initial;border-bottom-width:initial;border-left-width:initial;border-top-style:none;border-right-style:none;border-bottom-style:none;border-left-style:none;border-top-color:initial;border-right-color:initial;border-bottom-color:initial;border-left-color:initial;border-image-source:initial;border-image-slice:initial;border-image-width:initial;border-image-outset:initial;border-image-repeat:initial;background-color:transparent;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;" class="">/**
    Visitation protocol of the receiver's contiguous storage of immutable elements.
 */
protocol ContiguousBlock {

    /// Inferred alias to the element type to visit
    associatedtype Element

    /**
        Calls a closure with a pointer to the receiver's contiguous storage. If no such storage exists, it is first created.

        Often, the optimizer can eliminate bounds checks within an array algorithm, but when that fails, invoking the same algorithm on the buffer pointer passed into your closure lets you trade safety for speed.

        The following example shows how you can iterate over the contents of the buffer pointer:

            let numbers = [1, 2, 3, 4, 5]
            let sum = numbers.withUnsafeBufferPointer { buffer -&gt; Int in
                var result = 0
                for i in stride(from: buffer.startIndex, to: buffer.endIndex, by: 2) {
                    result += buffer[i]
                }
                return result
            }
            // 'sum' == 9

        - Parameter body: A closure with an `UnsafeBufferPointer` parameter that points to the contiguous storage for the receiver. If `body` has a return value, it is used as the return value for this method. The pointer argument is valid only for the duration of the closure's execution.

        - Returns: The return value of the `body` closure parameter, if any.

        - SeeAlso: Swift.UnsafeBufferPointer
     */
    func withUnsafeBufferPointer&lt;R&gt;(_ body: (UnsafeBufferPointer&lt;Element&gt;) throws -&gt; R) rethrows -&gt; R

}

/**
    Visitation protocol of the receiver's contiguous storage of elements, allowing mutation.
 */
protocol MutableContiguousBlock: ContiguousBlock {

    /**
        Calls the given closure with a pointer to the receiver's mutable contiguous storage. If no such storage exists, it is first created.

        Often, the optimizer can eliminate bounds checks within an array algorithm, but when that fails, invoking the same algorithm on the buffer pointer passed into your closure lets you trade safety for speed.

        The following example shows modifying the contents of the `UnsafeMutableBufferPointer` argument to `body` alters the contents of the receiver:

            var numbers = [1, 2, 3, 4, 5]
            numbers.withUnsafeMutableBufferPointer { buffer in
                for i in stride(from: buffer.startIndex, to: buffer.endIndex - 1, by: 2) {
                    swap(&amp;buffer[i], &amp;buffer[i + 1])
                }
            }
            print(numbers)
            // Prints "[2, 1, 4, 3, 5]"

        - Warning: Do not rely on anything about `self` (the receiver of this method) during the execution of the `body` closure: It may not appear to have its correct value. Instead, use only the `UnsafeMutableBufferPointer` argument to `body`.

        - Parameter body: A closure with an `UnsafeMutableBufferPointer` parameter that points to the contiguous storage for the receiver. If `body` has a return value, it is used as the return value for this method. The pointer argument is valid only for the duration of the closure's execution.

        - Returns: The return value of the `body` closure parameter, if any.

        - SeeAlso: withUnsafeBufferPointer, Swift.UnsafeMutableBufferPointer
     */
    mutating func withUnsafeMutableBufferPointer&lt;R&gt;(_ body: (inout UnsafeMutableBufferPointer&lt;Element&gt;) throws -&gt; R) rethrows -&gt; R

}</code><br class=""></pre></div><p style="margin: 15px 0px;" class=""><span class="highlight" style="background-color:rgb(255, 255, 255)"><span class="font" style="font-family:Helvetica, arial, sans-serif"><span class="size" style="font-size:14px">I don't know how the 3 library types implement this methods, but we know it can be done. If added as an implicit interface to built-in fixed-sized arrays, the implementers can use similar techniques or compiler magic. I don't know the difficulty to adapt these interfaces with third-party code.</span></span></span><br class=""></p><h2 style="margin-top:20px;margin-right:0px;margin-bottom:10px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;-webkit-font-smoothing:antialiased;position:relative;font-size:24px;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(204, 204, 204);font-family:Helvetica, arial, sans-serif;background-color:rgb(255, 255, 255);" class="">Source compatibility<br class=""></h2><p style="margin: 15px 0px;" class=""><span class="highlight" style="background-color:rgb(255, 255, 255)"><span class="font" style="font-family:Helvetica, arial, sans-serif"><span class="size" style="font-size:14px">The changes are strictly additive, and at the library level, so there should be no impact to existing code.</span></span></span><br class=""></p><h2 style="margin-top:20px;margin-right:0px;margin-bottom:10px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;-webkit-font-smoothing:antialiased;position:relative;font-size:24px;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(204, 204, 204);font-family:Helvetica, arial, sans-serif;background-color:rgb(255, 255, 255);" class="">Effect on ABI stability<br class=""></h2><p style="margin: 15px 0px;" class=""><span class="highlight" style="background-color:rgb(255, 255, 255)"><span class="font" style="font-family:Helvetica, arial, sans-serif"><span class="size" style="font-size:14px">These changes should not affect ABI stability.</span></span></span><br class=""></p><h2 style="margin-top:20px;margin-right:0px;margin-bottom:10px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;-webkit-font-smoothing:antialiased;position:relative;font-size:24px;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(204, 204, 204);font-family:Helvetica, arial, sans-serif;background-color:rgb(255, 255, 255);" class="">Effect on API resilience<br class=""></h2><p style="margin: 15px 0px;" class=""><span class="highlight" style="background-color:rgb(255, 255, 255)"><span class="font" style="font-family:Helvetica, arial, sans-serif"><span class="size" style="font-size:14px">As just stated, the addition of two protocol names to the API shouldn't affect the ABI.</span></span></span><br class=""></p><h2 style="margin-top:20px;margin-right:0px;margin-bottom:10px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;-webkit-font-smoothing:antialiased;position:relative;font-size:24px;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(204, 204, 204);font-family:Helvetica, arial, sans-serif;background-color:rgb(255, 255, 255);" class="">Alternatives considered<br class=""></h2><p style="margin: 15px 0px;" class=""><span class="highlight" style="background-color:rgb(255, 255, 255)"><span class="font" style="font-family:Helvetica, arial, sans-serif"><span class="size" style="font-size:14px">The main alternative is to do nothing. If fixed-sized arrays are later added, they could have the same methods too, but there would still be no common link.</span></span></span><br class=""></p><p style="margin-top: 15px; margin-right: 0px; margin-left: 0px; margin-bottom: 0px !important;" class=""><span class="highlight" style="background-color:rgb(255, 255, 255)"><span class="font" style="font-family:Helvetica, arial, sans-serif"><span class="size" style="font-size:14px">Another alternative would make&nbsp;<code style="margin-top:0px;margin-right:2px;margin-bottom:0px;margin-left:2px;padding-top:0px;padding-right:5px;padding-bottom:0px;padding-left:5px;white-space:nowrap;border-top-width:1px;border-right-width:1px;border-bottom-width:1px;border-left-width:1px;border-top-style:solid;border-right-style:solid;border-bottom-style:solid;border-left-style:solid;border-top-color:rgb(234, 234, 234);border-right-color:rgb(234, 234, 234);border-bottom-color:rgb(234, 234, 234);border-left-color:rgb(234, 234, 234);border-image-source:initial;border-image-slice:initial;border-image-width:initial;border-image-outset:initial;border-image-repeat:initial;background-color:rgb(248, 248, 248);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;" class="">MutableContiguousBlock</code>&nbsp;not inherit from&nbsp;<code style="margin-top:0px;margin-right:2px;margin-bottom:0px;margin-left:2px;padding-top:0px;padding-right:5px;padding-bottom:0px;padding-left:5px;white-space:nowrap;border-top-width:1px;border-right-width:1px;border-bottom-width:1px;border-left-width:1px;border-top-style:solid;border-right-style:solid;border-bottom-style:solid;border-left-style:solid;border-top-color:rgb(234, 234, 234);border-right-color:rgb(234, 234, 234);border-bottom-color:rgb(234, 234, 234);border-left-color:rgb(234, 234, 234);border-image-source:initial;border-image-slice:initial;border-image-width:initial;border-image-outset:initial;border-image-repeat:initial;background-color:rgb(248, 248, 248);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;" class="">ContiguousBlock</code>, meaning the former would need to define an&nbsp;<code style="margin-top:0px;margin-right:2px;margin-bottom:0px;margin-left:2px;padding-top:0px;padding-right:5px;padding-bottom:0px;padding-left:5px;white-space:nowrap;border-top-width:1px;border-right-width:1px;border-bottom-width:1px;border-left-width:1px;border-top-style:solid;border-right-style:solid;border-bottom-style:solid;border-left-style:solid;border-top-color:rgb(234, 234, 234);border-right-color:rgb(234, 234, 234);border-bottom-color:rgb(234, 234, 234);border-left-color:rgb(234, 234, 234);border-image-source:initial;border-image-slice:initial;border-image-width:initial;border-image-outset:initial;border-image-repeat:initial;background-color:rgb(248, 248, 248);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;" class="">Element</code>&nbsp;associated type. But don't see a need for a protocol with a read-write method without its read-only counterpart available.</span></span></span><br class=""></p></div>
<div class=""><br class=""></div>
<div style="font-family:Arial;" class=""><br class=""></div>
<div class=""><div style="letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-line-break: after-white-space;" class=""><div class="">—&nbsp;<br class=""></div>
<div class=""><div style="font-family:Arial;" class="">Daryle Walker<br class=""></div>
<div style="font-family:Arial;" class="">Mac, Internet, and Video Game Junkie<br class=""></div>
<div style="font-family:Arial;" class="">darylew AT mac DOT com&nbsp;<br class=""></div>
</div>
</div>
</div>
<div style="font-family:Arial;" class=""><br class=""></div>
<div class=""><u class="">_______________________________________________</u><br class=""></div>
<div class="">swift-evolution mailing list<br class=""></div>
<div class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""></div>
<div class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div>
</blockquote><div style="font-family:Arial;" class=""><br class=""></div>
</div>

_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></body></html>