<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 Sep 5, 2017, at 9:53 AM, Taylor Swift &lt;<a href="mailto:kelvin13ma@gmail.com" class="">kelvin13ma@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">we agreed to deprecate the strided <span style="font-family:monospace,monospace" class="">at:</span>? Note that UnsafeMutableRawBufferPointer would still need a <span style="font-family:monospace,monospace" class="">byteOffset:</span> argument. I’m also still not comfortable with duplicating functionality for the sake of having two names<br class=""></div></div></blockquote><div><br class=""></div>I’ll summarize what I think happened in this thread...<br class=""><div><br class=""></div><div>I don't think the suggested copyBytes rename was controversial:</div><div><br class=""></div><div>UMRP (raw pointer):</div><div>--- copyBytes(from:count)</div><div>+++ copyMemory(from:bytes:)</div><div><br class=""></div><div><br class=""></div><div>UMRBP (raw buffer):</div><div>--- copyBytes(from:)</div><div>+++ copyMemory(atByteOffset:from:)</div><div><br class=""></div><div>--- copyBytes&lt;C&gt;(from:)</div><div>+++ copyMemory(from:)</div><div><br class=""></div><div><br class=""></div><div>In the new raw initializeMemory methods, Xiaodi and I agreed to make</div><div>it more clear that the offset is in terms of `self` rather than</div><div>`from`, and to further reduce ambiguity by forcing manual stride</div><div>computation and using an explicit "offset" label. The call site will</div><div>be just as explicit as dropping down to `baseAddress` but without any</div><div>pointer conversion boilerplate.</div><div><br class=""></div><div>UMRBP (raw buffer):</div><div>+++ func initializeMemory&lt;T&gt;(atByteOffset:as:from:)</div><div>+++ func moveInitializeMemory&lt;T&gt;(atByteOffset:as:from:)</div><div><br class=""></div><div><br class=""></div><div>Than, in the one existing initializeMemory method, just drop the strided index.</div><div>It's never used, we want to be consistent in using a byte offset</div><div>for the raw index, and that can be expressed just as easily as pointer</div><div>arithmetic:</div><div><br class=""></div><div>UMRP (raw pointer):</div><div>--- func initializeMemory&lt;T&gt;(as:T.Type, at:Int = 0, count:Int = 1, to:T)</div><div>+++ func initializeMemory&lt;T&gt;(as:T.Type, repeating:T, count:Int = 1)</div><div><br class=""></div><div>Then you can simply leave these methods as-is:</div><div>&gt; func initializeMemory&lt;T&gt;(as:T.Type, from:UnsafePointer&lt;T&gt;, count:Int)</div><div>&gt; func moveInitializeMemory&lt;T&gt;(as:T.Type, from:UnsafeMutablePointer&lt;T&gt;, count:Int)&nbsp;</div><div><br class=""></div><div><br class=""></div><div>We don't have a consensus, but I think the suggestion to distinguish</div><div>between single value vs. multiple semantics was good. Otherwise,</div><div>adding the default count could be very misleading. Normally, we try to</div><div>minimize surface area, but adding two methods for the single-value case</div><div>avoids ambiguity between the buffer and pointer semantics:</div><div><br class=""></div><div>UMP (pointer)</div><div>--- func initialize(to:count:(=1))</div><div>+++ func initialize(to:)</div><div>+++ func initialize(repeating:count:) // no default count</div><div>+++ func assign(to:)</div><div>+++ func assign(repeating:count:) // no default count</div><div><br class=""></div><div>UMRP (raw pointer):</div><div>--- func initializeMemory&lt;T&gt;(as:at:(=0)count:(1)to:)</div><div>+++ func initializeMemory&lt;T&gt;(as:repeating:count:) // remove default count</div><div class=""><br class=""></div><div class="">-Andy</div><div class=""><br class=""></div><blockquote type="cite" class=""><div class=""><div class="gmail_extra"><div class="gmail_quote">On Tue, Sep 5, 2017 at 11:31 AM, Andrew Trick <span dir="ltr" class="">&lt;<a href="mailto:atrick@apple.com" target="_blank" class="">atrick@apple.com</a>&gt;</span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="">I think we’ve agreed to a few minor updates to this proposal. Since there hasn’t been any other feedback on the thread it may be worth posting an amended proposal so we all know what we’ve agreed on.<div class=""><br class=""></div><div class="">-Andy<br class=""><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class=""><div class="h5"><div class="">On Sep 3, 2017, at 8:23 PM, Andrew Trick via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="m_5074952175224083149Apple-interchange-newline"></div></div><div class=""><div class=""><div class="h5"><div style="word-wrap:break-word" class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Sep 3, 2017, at 8:05 PM, Xiaodi Wu &lt;<a href="mailto:xiaodi.wu@gmail.com" target="_blank" class="">xiaodi.wu@gmail.com</a>&gt; wrote:</div><br class="m_5074952175224083149Apple-interchange-newline"><div class=""><blockquote class="gmail_quote" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div class=""><div class="gmail_extra"><div class="gmail_quote"><div class="">If we use byte offset, then the<span class="m_5074952175224083149Apple-converted-space">&nbsp;</span><span style="font-family:monospace,monospace" class="">at</span><span class="m_5074952175224083149Apple-converted-space">&nbsp;</span>parameter in<span class="m_5074952175224083149Apple-converted-space">&nbsp;</span><span style="font-family:monospace,monospace" class="">UnsafeMutableRawPointer</span><span class="m_5074952175224083149Apple-converted-space">&nbsp;</span>sho<wbr class="">uld be removed, since pointer arithmetic can be used instead (just like with<span class="m_5074952175224083149Apple-converted-space">&nbsp;</span><span style="font-family:monospace,monospace" class="">UnsafeMutablePointer</span>).</div></div></div></div></blockquote><div dir="auto" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><br class=""></div><div dir="auto" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class="">I agree that it seems quite sensible to remove the ‘at’ parameter altogether from the UMRP method.</div></div></blockquote><div class=""><br class=""></div>No code in tree or on github is using the `at` argument. I think it can be removed. A fixit should still be possible.</div><div class=""><br class=""><blockquote type="cite" class=""><div class=""><blockquote class="gmail_quote" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div class=""><div class="gmail_extra"><div class="gmail_quote"><div class="">Not convinced moving the<span class="m_5074952175224083149Apple-converted-space">&nbsp;</span><span style="font-family:monospace,monospace" class="">at:</span><span class="m_5074952175224083149Apple-converted-space">&nbsp;</span>argument to come before the<span class="m_5074952175224083149Apple-converted-space">&nbsp;</span><span style="font-family:monospace,monospace" class="">as:</span><span class="m_5074952175224083149Apple-converted-space">&nbsp;</span>argument is worth it in terms of source breakage.</div></div></div></div></blockquote><div dir="auto" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><br class=""></div><div dir="auto" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class="">Since much of this proposal involves shuffling and relabeling arguments, I’d argue it’s better to break slight more source in one go for the optimal API than to break slightly less for a slightly less optimal API, no? (This is assuming there is agreement that ‘at:as:’ is less prone to misinterpretation than ‘as:at:’.)</div></div></blockquote></div><div class=""><br class=""></div><div class="">To be clear, we’re just talking about&nbsp;<wbr class="">UnsafeMutableRawBufferPointer.<wbr class="">initializeMemory now, so this is purely additive.</div><div class="">I think the label needs to be `atByteOffset`, and placing it before `as` makes a lot of sense because it no longer depends on the type’s stride.&nbsp;</div><div class=""><br class=""></div><div class="">-Andy</div></div></div></div><span class="">______________________________<wbr class="">_________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank" class="">https://lists.swift.org/<wbr class="">mailman/listinfo/swift-<wbr class="">evolution</a><br class=""></span></div></blockquote></div><br class=""></div></div></div></blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></body></html>