<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=""><div><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; -webkit-text-stroke-width: 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"><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 class=""><div class=""><div class=""><br class=""></div><div class="">In the new raw initializeMemory methods, Xiaodi and I agreed to make</div><div class="">it more clear that the offset is in terms of `self` rather than</div><div class="">`from`, and to further reduce ambiguity by forcing manual stride</div><div class="">computation and using an explicit "offset" label. The call site will</div><div class="">be just as explicit as dropping down to `baseAddress` but without any</div><div class="">pointer conversion boilerplate.</div><div class=""><br class=""></div><div class="">UMRBP (raw buffer):</div><div class="">+++ func initializeMemory&lt;T&gt;(atByteOffset:as:from:)</div><div class="">+++ func moveInitializeMemory&lt;T&gt;(atByteOffset:as:from:)</div><div class=""><br class=""></div></div></div></blockquote><div class=""><br class=""></div></div></div></div><div class=""><div class="gmail_extra"><div class="gmail_quote"><div class="">Agree, but the label should just be `<span style="font-family: monospace, monospace;" class="">atByte:</span>`, not `<span style="font-family: monospace, monospace;" class="">atByteOffset:</span>`. after all, we don’t use `<span style="font-family: monospace, monospace;" class="">atOffset:</span>` in the strided case; its obvious that it’s an offset</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; -webkit-text-stroke-width: 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; -webkit-text-stroke-width: 0px;" class="">The existing APIs use the terminology "byte offset"--for example, URP.load(fromByteOffset:as:). The rationale is that "at" without a noun that follows implies, per Swift API naming guidelines, "at index." If you want to specify, as we do here, what the index _is_, then it's written out in full.</div></div></blockquote><div><br class=""></div>Yes, it seems overly cumbersome, but I was following existing conventions which were intentionally very explicit.</div><div><br class=""><blockquote type="cite" 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; -webkit-text-stroke-width: 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=""></div></div></div></div><div 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 class=""><div class=""><div class=""><br class=""></div></div></div></blockquote></div></div></div><div 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 class=""><div class=""><div class=""></div><div class="">We don't have a consensus, but I think the suggestion to distinguish</div><div class="">between single value vs. multiple semantics was good. Otherwise,</div><div class="">adding the default count could be very misleading. Normally, we try to</div><div class="">minimize surface area, but adding two methods for the single-value case</div><div class="">avoids ambiguity between the buffer and pointer semantics:</div><div class=""><br class=""></div><div class="">UMP (pointer)</div><div class="">--- func initialize(to:count:(=1))</div><div class="">+++ func initialize(to:)</div><div class="">+++ func initialize(repeating:count:) // no default count</div><div class="">+++ func assign(to:)</div><div class="">+++ func assign(repeating:count:) // no default count</div><div class=""><br class=""></div><div class="">UMRP (raw pointer):</div><div class="">--- func initializeMemory&lt;T&gt;(as:at:(=0)count:(1)to:)</div><div class="">+++ func initializeMemory&lt;T&gt;(as:repeating:count:) // remove default count<span class="Apple-converted-space">&nbsp;</span><br class=""></div></div></div></blockquote><div class=""><br class=""></div></div></div></div><div class=""><div class="gmail_extra"><div class="gmail_quote"><div class="">still extremely suspicious of this but i’m willing to compromise. also there should be an `<span style="font-family: monospace, monospace;" class="">initializeMemory&lt;T&gt;(at:to:)</span>` to match the typed methods</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; -webkit-text-stroke-width: 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; -webkit-text-stroke-width: 0px;" class="">Do you mean initializeMemory&lt;T&gt;(as:to:)?</div></blockquote><div><br class=""></div><div>I don’t think it’s necessary since raw buffers are not normally used to hold a single typed element. We don’t need symmetry between raw and typed pointers and I wouldn’t want to add an API that will never be used. So, I would be ok with it only if there’s some use case that I’m overlooking.</div><div><br class=""></div><div>-Andy</div><div><br class=""></div><blockquote type="cite" 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; -webkit-text-stroke-width: 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"><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 class=""><div class=""><span class="m_868930590277175530gmail-"><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 class="Apple-converted-space">&nbsp;</span><span class="">&lt;<a href="mailto:atrick@apple.com" target="_blank" class="">atrick@apple.com</a>&gt;</span><span class="Apple-converted-space">&nbsp;</span>wrote:<br class=""><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 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="m_868930590277175530gmail-m_-5448707016195622191h5"><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_868930590277175530gmail-m_-5448707016195622191m_5074952175224083149Apple-interchange-newline"></div></div><div class=""><div class=""><div class="m_868930590277175530gmail-m_-5448707016195622191h5"><div 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_868930590277175530gmail-m_-5448707016195622191m_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_868930590277175530gmail-m_-5448707016195622191m_5074952175224083149Apple-converted-space">&nbsp;</span><span style="font-family: monospace, monospace;" class="">at</span><span class="m_868930590277175530gmail-m_-5448707016195622191m_5074952175224083149Apple-converted-space">&nbsp;</span>parameter in<span class="m_868930590277175530gmail-m_-5448707016195622191m_5074952175224083149Apple-converted-space">&nbsp;</span><span style="font-family: monospace, monospace;" class="">UnsafeMutableRawPointer</span><span class="m_868930590277175530gmail-m_-5448707016195622191m_5074952175224083149Apple-converted-space">&nbsp;</span>should be removed, since pointer arithmetic can be used instead (just like with<span class="m_868930590277175530gmail-m_-5448707016195622191m_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_868930590277175530gmail-m_-5448707016195622191m_5074952175224083149Apple-converted-space">&nbsp;</span><span style="font-family: monospace, monospace;" class="">at:</span><span class="m_868930590277175530gmail-m_-5448707016195622191m_5074952175224083149Apple-converted-space">&nbsp;</span>argument to come before the<span class="m_868930590277175530gmail-m_-5448707016195622191m_5074952175224083149Apple-converted-space">&nbsp;</span><span style="font-family: monospace, monospace;" class="">as:</span><span class="m_868930590277175530gmail-m_-5448707016195622191m_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;UnsafeMutableRawBufferPointer.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="">_______________________________________________<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/mailman/listinfo/swift-evolution</a></span></div></blockquote></div></div></div></div></blockquote></div></div></div></blockquote></span></div></div></blockquote></div></div></div></blockquote></blockquote></div><br class=""></body></html>