<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body><div style="font-family:Arial;">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.<br></div>
<div style="font-family:Arial;"><br></div>
<div id="sig40804545"><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></div>
<div class="signature"><span class="font" style="font-family:arial, sans-serif, sans-serif"> Zachary Waldowski</span><span class="font" style="font-family:arial, sans-serif, sans-serif"></span><br></div>
<div class="signature"><span class="font" style="font-family:arial, sans-serif, sans-serif"> </span><a href="mailto:zach@waldowski.me"><span class="font" style="font-family:arial, sans-serif, sans-serif">zach@waldowski.me</span></a><br></div>
</div>
<div><br></div>
<div><br></div>
<div>On Fri, Jan 27, 2017, at 06:40 PM, Daryle Walker via swift-evolution wrote:<br></div>
<blockquote type="cite"><div>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></div>
<div><br></div>
<div>(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></div>
<div><br></div>
<div><br></div>
<div><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;">Formal Protocol for Contiguous Storage Visitation<br></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);"><li style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;">Proposal: <a style="color:rgb(65, 131, 196);margin-top:0px;">SE-NNNN</a><br></li><li style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;">Authors: <a href="https://github.com/CTMacUser" style="color:rgb(65, 131, 196);margin-top:0px;">Daryle Walker</a><br></li><li style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;">Review Manager: TBD<br></li><li style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;">Status: <b>Awaiting review</b><br></li></ul><p style="margin: 15px 0px;"><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>During the review process, add the following fields as needed:</i></span></span></span><br></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);"><li style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;">Decision Notes: <a href="https://lists.swift.org/pipermail/swift-evolution/" style="color:rgb(65, 131, 196);margin-top:0px;">Rationale</a>, <a href="https://lists.swift.org/pipermail/swift-evolution/" style="color:rgb(65, 131, 196);">Additional Commentary</a><br></li><li style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;">Bugs: <a href="https://bugs.swift.org/browse/SR-NNNN" style="color:rgb(65, 131, 196);margin-top:0px;">SR-NNNN</a>, <a href="https://bugs.swift.org/browse/SR-MMMM" style="color:rgb(65, 131, 196);">SR-MMMM</a><br></li><li style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;">Previous Revision: <a href="https://github.com/apple/swift-evolution/blob/...commit-ID.../proposals/NNNN-filename.md" style="color:rgb(65, 131, 196);margin-top:0px;">1</a><br></li><li style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;">Previous Proposal: <a style="color:rgb(65, 131, 196);margin-top:0px;">SE-XXXX</a><br></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);">Introduction<br></h2><p style="margin: 15px 0px;"><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 <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;">Array</code>, <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;">ArraySlice</code>, and <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;">ContiguousArray</code> 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></p><p style="margin: 15px 0px;"><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></p><p style="margin: 15px 0px;"><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: <a href="https://lists.swift.org/pipermail/swift-evolution/" style="color:rgb(65, 131, 196);">Discussion thread topic for that proposal</a></span></span></span><br></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);">Motivation<br></h2><p style="margin: 15px 0px;"><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></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);">Proposed solution<br></h2><p style="margin: 15px 0px;"><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 <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;">MutableContiguousBlock</code>protocol, which inherits from the <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;">ContiguousBlock</code> protocol.</span></span></span><br></p><div style="font-family:Helvetica, arial, sans-serif;font-size:14px;background-color:rgb(255, 255, 255);"><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;"><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;">extension Array: MutableContiguousBlock {
}
extension ArraySlice: MutableContiguousBlock {
}
extension ContiguousArray: MutableContiguousBlock {
}</code><br></pre></div>
<p style="margin: 15px 0px;"><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></p><div style="font-family:Helvetica, arial, sans-serif;font-size:14px;background-color:rgb(255, 255, 255);"><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;"><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;">func change<T: MutableContiguousBlock>(object: inout T) -> T.Element where T.Element: Integer {
let sum = object.withUnsafeBufferPointer { (buffer) -> 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(&buffer[j], &buffer[j + 1])
}
}
return sum
}
var numbers = [1, 2, 3, 4, 5]
print(change(object: &numbers)) // 9
print(numbers) // [2, 1, 4, 3, 5]</code><br></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);">Detailed design<br></h2><div style="font-family:Helvetica, arial, sans-serif;font-size:14px;background-color:rgb(255, 255, 255);"><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;"><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;">/**
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 -> 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<R>(_ body: (UnsafeBufferPointer<Element>) throws -> R) rethrows -> 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(&buffer[i], &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<R>(_ body: (inout UnsafeMutableBufferPointer<Element>) throws -> R) rethrows -> R
}</code><br></pre></div>
<p style="margin: 15px 0px;"><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></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);">Source compatibility<br></h2><p style="margin: 15px 0px;"><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></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);">Effect on ABI stability<br></h2><p style="margin: 15px 0px;"><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></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);">Effect on API resilience<br></h2><p style="margin: 15px 0px;"><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></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);">Alternatives considered<br></h2><p style="margin: 15px 0px;"><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></p><p style="margin-top: 15px; margin-right: 0px; margin-left: 0px; margin-bottom: 0px !important;"><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 <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;">MutableContiguousBlock</code> not inherit from <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;">ContiguousBlock</code>, meaning the former would need to define an <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;">Element</code> 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></p></div>
<div><br></div>
<div style="font-family:Arial;"><br></div>
<div><div style="color:rgb(0, 0, 0);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;"><div>— <br></div>
<div><div style="font-family:Arial;">Daryle Walker<br></div>
<div style="font-family:Arial;">Mac, Internet, and Video Game Junkie<br></div>
<div style="font-family:Arial;">darylew AT mac DOT com <br></div>
</div>
</div>
</div>
<div style="font-family:Arial;"><br></div>
<div><u>_______________________________________________</u><br></div>
<div>swift-evolution mailing list<br></div>
<div><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br></div>
<div><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br></div>
</blockquote><div style="font-family:Arial;"><br></div>
</body>
</html>