<div dir="ltr">This proposal seems well thought-out to me; +1 as well.<div><br></div><div>Nits:</div><div><br></div><div>It seems the more natural order for the return value might be `(initializedUpTo: Index, unwritten: S.Iterator)`, since after all the call site is spelled `receiver.initialize(from: source)`.</div><div><br></div><div>Also, I&#39;d suggest having the label as `initializedUpTo` (rather than `initialized`) in the tuple return value for `UnsafeMutableRawBufferPointer.initialize(as:from:)` as well; if I understand correctly, it&#39;s supposed to be an UnsafeRawBufferPointer that points past the last byte written, so the pointee itself isn&#39;t actually initialized. (Plus, `initialized` could equally convey the unintended idea that the UnsafeRawBufferPointer points to the first of the initialized bytes.)</div><div class="gmail_extra"><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Dec 7, 2016 at 5:32 PM, Andrew Trick via swift-evolution <span dir="ltr">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><span class=""><br><div><blockquote type="cite"><div>On Nov 30, 2016, at 4:48 PM, Ben Cohen via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><br class="m_-3734189004417704526Apple-interchange-newline"><div><div style="word-wrap:break-word"><div><br></div><div>Hi swift-evolution,</div><div><br></div><div>Below is a draft proposal for a change to facilitate fixing some memory safety issues in the standard library.</div><div><br></div><div>If you’re interested in the implementation, PRs can be found here: <a href="https://github.com/apple/swift/pull/5521" target="_blank">[stdlib] [WIP] Eliminate version of Array.append(contentsOf:) that takes a Collection</a> and here: <a href="https://github.com/apple/swift/pull/5718" target="_blank">[stdlib] [WIP] Add UnsafeRawBufferPointer.<wbr>initialize(as:from:)</a></div><div>(they need a bit of performance work before they’re ready to land)</div><div><br></div><div><h2 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;line-height:1.25;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,&#39;Segoe UI&#39;,Helvetica,Arial,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;background-color:rgb(255,255,255)">Introduction</h2><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,&#39;Segoe UI&#39;,Helvetica,Arial,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)">The version of <code style="box-sizing:border-box;font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">UnsafeMutablePointer.<wbr>initialize(from:)</code> that takes a <code style="box-sizing:border-box;font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">Collection</code> should be deprecated in favour of a new method on <code style="box-sizing:border-box;font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">UnsafeMutableBufferPointer</code> <wbr>that takes a <code style="box-sizing:border-box;font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">Sequence</code>, with a goal of improving memory safety and enabling faster initialization of memory from sequences. Similarly, <code style="box-sizing:border-box;font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">UnsafeMutableRawPoi<wbr>nter.initializeMemory(as:from:<wbr>)</code> should be deprecated in favour of a new <code style="box-sizing:border-box;font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">UnsafeMutableRawBufferPoin<wbr>ter.initialize(as:from:)</code>.</p><h2 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;line-height:1.25;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,&#39;Segoe UI&#39;,Helvetica,Arial,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;background-color:rgb(255,255,255)"><a id="m_-3734189004417704526user-content-motivation" class="m_-3734189004417704526anchor" href="https://github.com/airspeedswift/swift-evolution/blob/b1d05032567e5c7b469f3ccca1bc1a42175a2400/proposals/NNNN-move-unsafe-initialize-from.md#motivation" style="box-sizing:border-box;background-color:transparent;color:rgb(64,120,192);text-decoration:none;float:left;padding-right:4px;line-height:1" target="_blank"><u></u><u></u><u></u><u></u></a></h2></div></div></div></blockquote></div><br></span><div>+1 on this proposal.</div><div><br></div><div>(looks like I had forgotten to reply to the list)</div><div><br></div><div>-Andy</div></div><br>______________________________<wbr>_________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br>
<br></blockquote></div><br></div></div>