<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 2, 2017, at 5:34 PM, Xiaodi Wu &lt;<a href="mailto:xiaodi.wu@gmail.com" class="">xiaodi.wu@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">On Sat, Sep 2, 2017 at 4:41 PM, 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=""><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="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 style="word-wrap:break-word" class=""><span class="gmail-"><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Sep 2, 2017, at 2:06 PM, Taylor Swift via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="gmail-m_-7332612120152683601Apple-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 dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><span class="gmail-m_-7332612120152683601gmail-"><blockquote class="gmail_quote" style="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 dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class="">the subscript doesn’t know about the stride that you want to use. If you want to get rid of the `<span style="font-family:monospace,monospace" class="">at:</span>` ambiguity, you have to get rid of it everywhere, or users will just wind up having to remember two ways (one ambiguous and one less ambiguous) of doing the same thing, instead of one (ambiguous) way of doing it.<br class=""></div></div></div></div></blockquote><div class=""><br class=""></div></span><div class="">Certainly, that's a good point. On rethink and another re-reading of the proposal, it's unclear to me that the addition of `at` arguments to UnsafeMutablePointer is sufficiently justified by the proposal text. Is it merely that it's shorter than writing `foo + MemoryLayout&lt;T&gt;.stride * offset`? With the ambiguity of `at`, it seems that the current way of writing it, though longer, is certainly less ambiguous.<span class="gmail-m_-7332612120152683601Apple-converted-space">&nbsp;</span><br class=""></div></div></div></div></blockquote><div 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 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="">Please reread it;<span class="gmail-m_-7332612120152683601Apple-converted-space">&nbsp;</span><span style="font-family:monospace,monospace" class="">UnsafeMutablePointer</span>’s methods do<span class="gmail-m_-7332612120152683601Apple-converted-space">&nbsp;</span><i class="">not</i><span class="gmail-m_-7332612120152683601Apple-converted-space">&nbsp;</span>use `<span style="font-family:monospace,monospace" class="">at:</span>`.</div></div></blockquote></div><br class=""></span><div class="">Regarding the typed buffer pointers, I think it is clear by convention, and will be well documented, that the `at` label refers to a position in `self`.</div><div class=""><br class=""></div><div class="">The raw buffer pointer API isn’t so obvious. Since the `at` refers to `self` it might more logically be a byte offset. Note that `at` as a label name always refers to a strided index.</div><div class=""><br class=""></div><div class="">This would be a bit more explicit:</div><div class="">UnsafeRawBufferPointer.<wbr class="">initializeMemory(as:T.self, atByteOffset: position * MemoryLayout&lt;T&gt;.stride, from: bufferOfT)</div><div class=""><br class=""></div><div class="">But possibly less convenient… Since that `at` label currently on UnsafeRawPointer.<wbr class="">initializeMemory is almost never used, I don’t think we need to worry too much about convenience.</div><div class=""><br class=""></div><div class="">That existing `at` label on UnsafeRawPointer.<wbr class="">initializeMemory, would also need to be renamed, which is fine.</div></div></blockquote><div class=""><br class=""></div><div class="">If I may suggest one more incremental improvement in clarity, it would be to move `at[ByteOffset]` to be the first argument; this eliminates the possible reading that we are offsetting the source buffer:</div><div class=""><br class=""></div><div class="">```</div><div class="">UnsafeRawBufferPointer.<wbr class="">initializeMemory(atByteOffset: position * MemoryLayout&lt;T&gt;.stride, as:T.self, from: bufferOfT)</div><div class="">```</div></div></div></div>
</div></blockquote></div><br class=""><div class="">Sure, that probably makes sense if we decide to go with a byte offset vs. stride index.</div><div class="">-Andy</div></body></html>