<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Sep 2, 2017 at 3:39 PM, Xiaodi Wu <span dir="ltr">&lt;<a href="mailto:xiaodi.wu@gmail.com" target="_blank">xiaodi.wu@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><span class="gmail-">On Sat, Sep 2, 2017 at 2:13 PM, Taylor Swift <span dir="ltr">&lt;<a href="mailto:kelvin13ma@gmail.com" target="_blank">kelvin13ma@gmail.com</a>&gt;</span> wrote:<br></span><div class="gmail_extra"><div class="gmail_quote"><span class="gmail-"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span class="gmail-m_-229495358743864938gmail-">On Sat, Sep 2, 2017 at 10:03 AM, Xiaodi Wu 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:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><span class="gmail-m_-229495358743864938gmail-m_3092102892467842161gmail-">On Sat, Sep 2, 2017 at 12:27 AM, Douglas Gregor 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></span><div class="gmail_extra"><div class="gmail_quote"><span class="gmail-m_-229495358743864938gmail-m_3092102892467842161gmail-"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,BlinkMacSystemFont,&quot;Segoe UI&quot;,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;,&quot;Segoe UI Symbol&quot;;font-size:16px;background-color:rgb(255,255,255)">Hello Swift community,</p><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,BlinkMacSystemFont,&quot;Segoe UI&quot;,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;,&quot;Segoe UI Symbol&quot;;font-size:16px;background-color:rgb(255,255,255)">The review of SE-0184 &quot;Unsafe[Mutable][Raw][Buffer]P<wbr>ointer: add missing methods, adjust existing labels for clarity, and remove deallocation size&quot; begins now and runs through September 7, 2017. The proposal is available here:</p><blockquote style="box-sizing:border-box;margin:0px 0px 16px;padding:0px 1em;border-left:0.25em solid rgb(223,226,229);background-color:rgb(255,255,255)"><div style="box-sizing:border-box;margin-top:0px;margin-bottom:0px"><font size="3" color="#6a737d" face="-apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><a href="https://github.com/apple/swift-evolution/blob/master/proposals/0184-unsafe-pointers-add-missing.md" target="_blank">https://github.com/apple/swift<wbr>-evolution/blob/master/proposa<wbr>ls/0184-unsafe-pointers-add-mi<wbr>ssing.md</a></font></div></blockquote><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,BlinkMacSystemFont,&quot;Segoe UI&quot;,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;,&quot;Segoe UI Symbol&quot;;font-size:16px;background-color:rgb(255,255,255)">Reviews are an important part of the Swift evolution process. All reviews should be sent to the swift-evolution mailing list at</p><blockquote style="box-sizing:border-box;margin:0px 0px 16px;padding:0px 1em;color:rgb(106,115,125);border-left:0.25em solid rgb(223,226,229);font-family:-apple-system,BlinkMacSystemFont,&quot;Segoe UI&quot;,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;,&quot;Segoe UI Symbol&quot;;font-size:16px;background-color:rgb(255,255,255)"><div style="box-sizing:border-box;margin-top:0px;margin-bottom:0px"><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration:none" target="_blank">https://lists.swift.org/mailma<wbr>n/listinfo/swift-evolution</a></div></blockquote><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,BlinkMacSystemFont,&quot;Segoe UI&quot;,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;,&quot;Segoe UI Symbol&quot;;font-size:16px;background-color:rgb(255,255,255)">or, if you would like to keep your feedback private, directly to the review manager. When replying, please try to keep the proposal link at the top of the message:</p><blockquote style="box-sizing:border-box;margin:0px 0px 16px;padding:0px 1em;border-left:0.25em solid rgb(223,226,229);background-color:rgb(255,255,255)"><p style="color:rgb(106,115,125);font-family:-apple-system,BlinkMacSystemFont,&quot;Segoe UI&quot;,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;,&quot;Segoe UI Symbol&quot;;font-size:16px;box-sizing:border-box;margin-top:0px;margin-bottom:16px">Proposal link:</p><blockquote style="box-sizing:border-box;margin:0px;padding:0px 1em;border-left:0.25em solid rgb(223,226,229)"><div style="box-sizing:border-box;margin-top:0px;margin-bottom:0px"><font size="3" color="#6a737d" face="-apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><a href="https://github.com/apple/swift-evolution/blob/master/proposals/0184-unsafe-pointers-add-missing.md" target="_blank">https://github.com/apple/swift<wbr>-evolution/blob/master/proposa<wbr>ls/0184-unsafe-pointers-add-mi<wbr>ssing.md</a></font></div></blockquote></blockquote><blockquote style="box-sizing:border-box;margin:0px 0px 16px;padding:0px 1em;color:rgb(106,115,125);border-left:0.25em solid rgb(223,226,229);font-family:-apple-system,BlinkMacSystemFont,&quot;Segoe UI&quot;,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;,&quot;Segoe UI Symbol&quot;;font-size:16px;background-color:rgb(255,255,255)"><div style="box-sizing:border-box;margin-top:0px;margin-bottom:0px">Reply text</div></blockquote><blockquote style="box-sizing:border-box;margin:0px 0px 16px;padding:0px 1em;color:rgb(106,115,125);border-left:0.25em solid rgb(223,226,229);font-family:-apple-system,BlinkMacSystemFont,&quot;Segoe UI&quot;,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;,&quot;Segoe UI Symbol&quot;;font-size:16px;background-color:rgb(255,255,255)"><blockquote style="box-sizing:border-box;margin:0px;padding:0px 1em;border-left:0.25em solid rgb(223,226,229)"><div style="box-sizing:border-box;margin-top:0px;margin-bottom:0px">Other replies</div></blockquote></blockquote><h5 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;font-size:0.875em;line-height:1.25;color:rgb(36,41,46);font-family:-apple-system,BlinkMacSystemFont,&quot;Segoe UI&quot;,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;,&quot;Segoe UI Symbol&quot;;background-color:rgb(255,255,255)"><a id="gmail-m_-229495358743864938gmail-m_3092102892467842161gmail-m_-1827723946451240259gmail-m_-3811060451040046695user-content-what-goes-into-a-review-1" class="gmail-m_-229495358743864938gmail-m_3092102892467842161gmail-m_-1827723946451240259gmail-m_-3811060451040046695anchor" href="https://github.com/apple/swift-evolution/pulls#what-goes-into-a-review-1" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration:none;float:left;padding-right:4px;line-height:1" target="_blank"><u></u><u></u><u></u><u></u></a>What goes into a review?</h5><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,BlinkMacSystemFont,&quot;Segoe UI&quot;,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;,&quot;Segoe UI Symbol&quot;;font-size:16px;background-color:rgb(255,255,255)">The goal of the review process is to improve the proposal under review through constructive criticism and, eventually, determine the direction of Swift. When writing your review, here are some questions you might want to answer in your review:</p><ul style="box-sizing:border-box;padding-left:2em;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,BlinkMacSystemFont,&quot;Segoe UI&quot;,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;,&quot;Segoe UI Symbol&quot;;font-size:16px;background-color:rgb(255,255,255)"><li style="box-sizing:border-box">What is your evaluation of the proposal?</li></ul></div></blockquote></span><div>Overall, this is an improvement. However, I do have some questions and concerns:</div><div><br></div><div><br></div><div>Questions:</div><div><br></div><div>## UnsafeMutableRawPointer</div><div><br></div><div><div>Regarding the options given for &quot;whose `count` to use&quot;--which option is actually being proposed?</div></div></div></div></div></blockquote><div><br></div></span><div>I don’t understand the question,, `<span style="font-family:monospace,monospace">UnsafeMutableRawPointer</span>` takes an explicit `<span style="font-family:monospace,monospace">count:</span>`. the “whose count to use” option is irrelevant.</div></div></div></div></blockquote><div><br></div></span><div>In &quot;Proposed Solution,&quot; under subheading &quot;UnsafeMutableRawPointer,&quot; you write &quot;the question of whose `count` to use becomes important.&quot; You then outline &quot;[o]ne option&quot; as well as &quot;[a] better option.&quot; Which of these options are you actually proposing? For clarity, could you please excise the non-proposed option from the &quot;Proposed Solution&quot; section and move it to the &quot;Alternatives Considered&quot; section?</div></div></div></div></blockquote><div><br></div><div>The <i>Proposed solution</i> section is divided into two parts, one dealing with plain pointers and one dealing with buffer pointers. The sections are separated by the horizontal rule above “<i>Buffer pointers are conceptually similar…</i>”. I don’t know why we’re arguing over typographic formatting but I am glad this proposal is noncontroversial enough to induce debate over its horizontal rules. As for the two options, the first is a strawman to explain why we are going with the second option.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class="gmail-"><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class="gmail-m_-229495358743864938gmail-"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><div>## UnsafeMutableBufferPointer</div><div><br></div><div>Please clarify: why are you proposing that the `at:` arguments in `UnsafeMutableBufferPointer` and `UnsafeMutableRawBufferPointer<wbr>` _should not_ receive default values, but the `at:` arguments in `UnsafeMutableRawPointer` _should_ receive a default value of `0`?</div></div><div><br></div></div></div></div></blockquote><div><br></div></span><div> The extant API for `<span style="font-family:monospace,monospace">UnsafeMutableRawPointer</span>` already included these default arguments which seem to be widely used in the stdlib,, the proposal tries to avoid these kinds of source breakages wherever possible. We avoid providing the default arguments on buffer pointers because we want the fact that it takes a <i>start–length</i> segment pair to be obvious at the call site.</div></div></div></div></blockquote><div><br></div></span><div>Thanks for the clarification; that would be helpful information to put into the proposal text. It is not an intuitive start-length pair, since the `at` refers to an offset of the destination buffer but `count` refers to a length of the source buffer. I appreciate how you separated the proposed new argument `at` and the existing argument `count` in what is currently named `initializeMemory&lt;T&gt;(as:from:<wbr>count:)`, which helps to reinforce that fact.</div><span class="gmail-"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class="gmail-m_-229495358743864938gmail-"><div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div></div><div>Concerns:</div><div><br></div><div>## UnsafeMutablePointer</div><div><br></div><div>It&#39;s alarming that omitting `count` in `initialize(repeating:count:)` (and assign, etc.) means initialize _one_ element, but elsewhere (such as `UnsafeMutableBufferPointer` means initialize _all_ elements. The behavior of the proposed API also contradicts its own spelling on its face: `initialize(repeating: foo)` means *do not repeat* `foo`.</div><div><br></div><div>Yes, I understand the argument that `*BufferPointer` types have an intrinsic count, etc., but in the context of code where types are inferred, `let foo = T.allocate(capacity: 100); foo.initialize(repeating: bar)` should not mean one thing for `*BufferPointer` types and a totally different thing for plain `*Pointer` types--particularly when both can be allocated with a certain capacity greater than one.</div><div><br></div><div>Either `count` should always be required, or for convenience there should be a separate overload `initialize(pointee:)` that does not require `count`.</div><div><br></div></div></div></div></blockquote><div><br></div></span><div>I understand the naming is not optimal, but reams of discussion on this list have concluded that it’s the least bad alternative available. We can’t just get rid of the default value for `<span style="font-family:monospace,monospace">count:</span>` because usage in real code bases shows that this default argument is actually extremely useful. I believe well over 90% of the calls to these methods in the standard library currently rely on the default argument value. Renaming the `repeating:` argument to `to:` would make the API inconsistent and hide the fact that plain pointers are still capable of operating on many elements in sequence — “`<span style="font-family:monospace,monospace">to:count:</span>`” makes no grammatical sense to read — “to” is a singular preposition.<br></div></div></div></div></blockquote><div><br></div></span><div>Let me clarify my concern here. This is not intended to be a bikeshedding exercise and I agree with your choice of `repeating` (as I did in the original conversations). For the sake of clarity, however, I&#39;ll proceed with this discussion as though the argument were named `xxxx`. My point here is that, regardless of what `xxxx` is called, we have a problem here as follows:</div><div><br></div><div>```</div><div>let foo = UnsafeMutablePointer&lt;Int&gt;.<wbr>allocate(capacity: 21)</div><div>foo.initialize(xxxx: 42) // initializes 1 value</div><div><br></div><div>let bar = UnsafeMutableBufferPointer&lt;<wbr>Int&gt;.allocate(capacity: 21)</div><div>bar.initialize(xxxx: 42) // initializes 21 values</div><div>```</div><div><br></div><div>The same spelling, `initialize(xxxx:)`, does two *different* things under your proposal depending on whether it&#39;s invoked on a UMP or a UMBP. Even though it&#39;s admirable that your proposal is filling in the gaps of Swift&#39;s pointer design and increasing consistency by making similar things have similar names, different things need to have different names; otherwise, we are actively creating footguns.</div><div><br></div><div>Therefore, while I agree with your choice for `xxxx`, and while I also agree that it is very useful to have a method that initializes a single value on a UMP, we need to have a different label `yyyy` for that method. My suggestion is `pointee`, but I would be equally happy with `value`, `to`, or whatever else you may choose. <br></div></div></div></div></blockquote><div><br></div><div>yes this is a problem, but your solution is to add a second set of methods that are functionally identical, except for the names of the argument labels. This strikes me as silly and wasteful of API surface.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div></div><span class="gmail-"><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class="gmail-m_-229495358743864938gmail-"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>## UnsafeMutableRawBufferPointer</div><div><br></div><div>In `copyBytes`, the use of `Bytes` to emphasize that it&#39;s the memory that&#39;s being copied is thoughtful, but it is inconsistent with the other method names that use the terminology `Memory` for the same purpose (e.g., `moveInitializeMemory` to clarify the meaning of `moveInitialize`).</div><div><br></div><div>For better consistency--and since you&#39;re proposing to rename `copyBytes(from:count:)` on `UnsafeMutableRawPointer` to `copy(from:bytes:)`--this particular API on `UnsafeMutableRawBufferPointer<wbr>` should be named `copyMemory(from:)` and not `copyBytes(from:)`.</div><div><br></div><div>Although, actually, looking at the APIs on `UnsafeMutableRawPointer` itself, that particular method too might best be written as `copyMemory(from:bytes:)` instead of merely `copy(from:bytes:)` for better consistency with the rest of the methods on that type as well.</div><div><br></div><div><br></div></div></div></div></blockquote><div><br></div></span><div>“Memory” methods are distinct from “Bytes” methods in that they assume typed memory. “Bytes” on the other hand does not care about types.</div></div></div></div></blockquote><div><br></div></span><div>It&#39;s unclear to me that this distinction is either consistently observed or helpful. For instance, by that standard, `initializeMemory(as:from:)` should be named `initializeBytes(as:<wbr>fromMemory:)`, since the memory being initialized is raw until after initialization. This strikes me as not at all necessary for user comprehension of the APIs. (On the other hand, if it _is_ necessary for comprehension, then `copyBytes` should never be shortened to `copy`, since it would be necessary to emphasize that both the source and destination are treated as &quot;bytes&quot; rather than &quot;memory.&quot;)</div></div></div></div></blockquote><div><br></div><div>`copyMemory` would probably be better and I am not opposed to adding it to the proposal. at the same time I don’t think it’s so bad a problem that it really <i>needs</i> to be renamed.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class="gmail-"><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class="gmail-m_-229495358743864938gmail-"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div></div><div>## General comment</div><div><br></div><div><div>Many `at:` arguments, especially such as in the case of `copyBytes(at:from:)`, make sense only when read in a list with all other methods. Standing alone, `at` is ambiguous as to whether it&#39;s referring to the _source_ or the _destination_. Why do these APIs on `*BufferPointer` types not take advantage of subscripts? That is, why not:<br></div><div><br></div><div>  `foo[x...].copyMemory(from: bar)`</div><div><br></div><div>instead of</div><div><br></div><div>  `foo.copyBytes(at: x, from: bar)`</div><div><br></div><div>The first seems dramatically clearer as to its meaning. The same feedback applies to nearly all uses of `at` on `*BufferPointer` types: they would seem to be greatly clarified (in terms of the &quot;what does `at` mean&quot; question) by the use of a subscript spelling.</div></div></div></div></div></blockquote><div><br></div></span><div>This idea sounds elegant on the surface but it’s deeply problematic. `<span style="font-family:monospace,monospace">foo[x...]</span>` suggests that whatever happens to it, will happen to the entire rest of the buffer slice as well, which is not always the case.</div></div></div></div></blockquote><div><br></div></span><div>No more so than `foo.copyBytes(at:from:)` suggests the same?</div></div></div></div></blockquote><div><br></div><div>`<span style="font-family:monospace,monospace">at:</span>` suggests an unbounded starting point. `<span style="font-family:monospace,monospace">x...</span>` suggests a concrete range of the buffer since it’s really shorthand for `<span style="font-family:monospace,monospace">x ... endIndex</span>`.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class="gmail-"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>It would have to be written as `<span style="font-family:monospace,monospace">foo[x ... x + count].copyMemory(from: bar)</span>` or `<span style="font-family:monospace,monospace">foo[x ... x + bar.count].copyMemory(from: bar)</span>` which seems <i>less</i> clear.  Having to write `<span style="font-family:monospace,monospace">foo[0...]</span>` to operate with no offset also seems silly.</div></div></div></div></blockquote><div><br></div></span><div>It is unclear to me why one would have to write `foo[0...]`. <br></div></div></div></div></blockquote><div><br></div><div>How else would you operate at offset 0?<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div></div><span class="gmail-"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>It also means the API would have to be written on `<span style="font-family:monospace,monospace">MutableRandomAccessSlice&lt;Unsa<wbr>feMutable*BufferPointer&gt;</span>`.</div></div></div></div></blockquote><div><br></div></span><div>Not necessarily; it&#39;s unclear to me that `MutableRandomAccessSlice&lt;<wbr>UnsafeMutable*BufferPointer&gt;` is the right slice type for `UnsafeMutable*BufferPointer` in the first place (see below).</div><span class="gmail-"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>Finally, what happens when you subscript a raw pointer?</div></div></div></div></blockquote><div><br></div></span><div>As you know, only buffer pointers conform to `Collection`, so it&#39;s unclear to me what your question is here. <br></div></div></div></div></blockquote><div><br></div><div>I meant a raw <i>buffer</i> pointer.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div></div><span class="gmail-"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>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">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></div></div></div></div></blockquote><div><br></div></span><div>Certainly, that&#39;s a good point. On rethink and another re-reading of the proposal, it&#39;s unclear to me that the addition of `at` arguments to UnsafeMutablePointer is sufficiently justified by the proposal text. Is it merely that it&#39;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. <br></div></div></div></div></blockquote><div><br></div><div>Please reread it; <span style="font-family:monospace,monospace">UnsafeMutablePointer</span>’s methods do <i>not</i> use `<span style="font-family:monospace,monospace">at:</span>`.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div></div><span class="gmail-"><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class="gmail-m_-229495358743864938gmail-"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><div>I notice that you comment that you feel there are ergonomic issues with buffer pointer slicing; can you please comment on what is &quot;wasteful&quot; currently? Is there a performance hit to slicing a `*BufferPointer` type? If so, we should fix that, as the whole rationale of having these types (as I understand it) is to improve the ergonomics of working with pointers to multiple elements by conforming them to `*Collection` APIs.</div></div></div></div></div></blockquote><div><br></div></span><div>Slices are not the right abstraction for this because of Swift’s indexing semantics.</div></div></div></div></blockquote><div><br></div></span><div>This is an alarming statement if true, in that it would seem to undermine the basic premise of `*BufferPointer` types conforming to `Collection`, would it not? <br></div></div></div></div></blockquote><div><br></div><div>I think Andy’s message has a good explanation for this.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div></div><span class="gmail-"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>A buffer pointer requires two words of information (beginning and end address), while a buffer pointer slice occupies four words of information (beginning, end, start-index, end-index) to preserve the index semantics. Creating a way to “slice” a buffer pointer into another buffer pointer without going through `<span style="font-family:monospace,monospace">init(rebasing:)</span>` is also problematic because you can’t `<span style="font-family:monospace,monospace">deallocate()</span>` a debased buffer pointer, so we should make that operation explicit.</div></div></div></div></blockquote><div><br></div></span><div>It would seem, then, that to properly support slicing--which collection types should do--we will need a custom slice type a la `Substring`. This slice type would clearly not support deallocation, but it would conform to a protocol (a la `StringProtocol`) which would require all the operations such as `copyMemory` that makes sense for both buffer pointers and their slices. <br></div></div></div></div></blockquote><div><br></div><div>You’re basically proposing Protocol Oriented Pointers. Probably a good eventual goal, but we need to take things step by step. <br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div></div><span class="gmail-"><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class="gmail-m_-229495358743864938gmail-"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><div>It seems deeply unsatisfactory to invent new methods that use `at:` arguments _on a type whose purpose is to expose `*Collection` APIs_ if we agree that the slicing notation is demonstrably clearer. I do not have the same concerns about adding `at:` arguments to `UnsafeMutableRawPointer` methods, which are quite appropriate.</div></div><span class="gmail-m_-229495358743864938gmail-m_3092102892467842161gmail-"><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><ul style="box-sizing:border-box;padding-left:2em;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,BlinkMacSystemFont,&quot;Segoe UI&quot;,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;,&quot;Segoe UI Symbol&quot;;font-size:16px;background-color:rgb(255,255,255)"><li style="box-sizing:border-box;margin-top:0.25em">Is the problem being addressed significant enough to warrant a change to Swift?</li></ul></div></blockquote></span><div>Yes.</div><span class="gmail-m_-229495358743864938gmail-m_3092102892467842161gmail-"><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><ul style="box-sizing:border-box;padding-left:2em;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,BlinkMacSystemFont,&quot;Segoe UI&quot;,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;,&quot;Segoe UI Symbol&quot;;font-size:16px;background-color:rgb(255,255,255)"><li style="box-sizing:border-box;margin-top:0.25em">Does this proposal fit well with the feel and direction of Swift?</li></ul></div></blockquote></span><div>In parts, yes. In others (see above), it could be improved to fit better with the feel and direction of other Swift APIs.</div><span class="gmail-m_-229495358743864938gmail-m_3092102892467842161gmail-"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><ul style="box-sizing:border-box;padding-left:2em;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,BlinkMacSystemFont,&quot;Segoe UI&quot;,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;,&quot;Segoe UI Symbol&quot;;font-size:16px;background-color:rgb(255,255,255)"><li style="box-sizing:border-box;margin-top:0.25em">If you have used other languages or libraries with a similar feature, how do you feel that this proposal compares to those?</li></ul></div></blockquote></span><div>There is much more friction to using pointers in Swift than in C. However, making Swift pointers like C pointers is clearly a non-goal. This proposal appropriate addresses major pain points to Swift-specific usages of pointers.</div><span class="gmail-m_-229495358743864938gmail-m_3092102892467842161gmail-"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><ul style="box-sizing:border-box;padding-left:2em;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,BlinkMacSystemFont,&quot;Segoe UI&quot;,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;,&quot;Segoe UI Symbol&quot;;font-size:16px;background-color:rgb(255,255,255)"><li style="box-sizing:border-box;margin-top:0.25em">How much effort did you put into your review? A glance, a quick reading, or an in-depth study?</li></ul></div></blockquote></span><div>A moderately thorough reading, drawing on some experience using pointer APIs in Swift, and based on prior readings of previous iterations of this proposal and the on-list discussion.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-m_-229495358743864938gmail-m_3092102892467842161gmail-"><div><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,BlinkMacSystemFont,&quot;Segoe UI&quot;,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;,&quot;Segoe UI Symbol&quot;;font-size:16px;background-color:rgb(255,255,255)">More information about the Swift evolution process is available at</p><blockquote style="box-sizing:border-box;margin:0px 0px 16px;padding:0px 1em;color:rgb(106,115,125);border-left:0.25em solid rgb(223,226,229);font-family:-apple-system,BlinkMacSystemFont,&quot;Segoe UI&quot;,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;,&quot;Segoe UI Symbol&quot;;font-size:16px;background-color:rgb(255,255,255)"><div style="box-sizing:border-box;margin-top:0px;margin-bottom:0px"><a href="https://github.com/apple/swift-evolution/blob/master/process.md" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration:none" target="_blank">https://github.com/apple/swift<wbr>-evolution/blob/master/process<wbr>.md</a></div></blockquote><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,BlinkMacSystemFont,&quot;Segoe UI&quot;,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;,&quot;Segoe UI Symbol&quot;;font-size:16px;background-color:rgb(255,255,255)">Thank you,</p><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,BlinkMacSystemFont,&quot;Segoe UI&quot;,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;,&quot;Segoe UI Symbol&quot;;font-size:16px;background-color:rgb(255,255,255)">-Doug</p><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,BlinkMacSystemFont,&quot;Segoe UI&quot;,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;,&quot;Segoe UI Symbol&quot;;font-size:16px;background-color:rgb(255,255,255)">Review Manager</p></div><br></span>______________________________<wbr>_________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailma<wbr>n/listinfo/swift-evolution</a><br>
<br></blockquote></div><br></div></div>
<br>______________________________<wbr>_________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailma<wbr>n/listinfo/swift-evolution</a><br>
<br></blockquote></span></div><br></div></div>
</blockquote></span></div><br></div></div>
</blockquote></div><br></div></div>