<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 Jul 11, 2016, at 10:22 AM, Dave Abrahams &lt;<a href="mailto:dabrahams@apple.com" class="">dabrahams@apple.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">on Mon Jul 11 2016, Andrew Trick &lt;</span><a href="http://atrick-at-apple.com/" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">atrick-AT-apple.com</a><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">&gt; wrote:</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" class="">On Jul 11, 2016, at 12:50 AM, Ben Rimmington &lt;<a href="mailto:me@benrimmington.com" class="">me@benrimmington.com</a>&gt; wrote:<br class=""><br class=""><br class=""><blockquote type="cite" class="">On 10 Jul 2016, at 14:41, Andrew Trick via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""><br class=""></blockquote></blockquote><br class=""><blockquote type="cite" class=""><blockquote type="cite" class="">I'm revising this proposal based on last week's feedback. A few of the<br class="">additive APIs are removed and a number of UnsafePointer and<br class="">UnsafeRawPointer methods are renamed.<br class=""><br class="">Here is a PR for the revision. Note that the examples in the proposal<br class="">text still need to be updated:<br class=""><a href="https://github.com/apple/swift-evolution/pull/420" class="">https://github.com/apple/swift-evolution/pull/420</a><br class=""><br class="">I updated the short-form summary of the API:<br class="">https://github.com/atrick/swift-evolution/blob/3122ace9d2fb55072ebd7395c7353fcbf497318a/proposals/0107-unsaferawpointer.md#full-unsaferawpointer-api<br class=""><br class="">The full UnsafeRawPointer API with doc comments is here:<br class="">https://github.com/atrick/swift/blob/22e3a2885e4236888ec447a7148acf633d8544f5/stdlib/public/core/UnsafeRawPointer.swift.gyb<br class=""><br class="">The UnsafePointer and UnsafeRawPointer changes are on this branch:<br class="">https://github.com/atrick/swift/commits/rawptr<br class=""><br class="">If you wish to comment line-by-line on the detailed docs or<br class="">implementation, you can do so here:<br class="">https://github.com/apple/swift/pull/3437<br class=""><br class="">---<br class="">The only concern I have about this version of the proposal is this method name:<span class="Apple-converted-space">&nbsp;</span><br class=""><br class="">func copyBytes(from: UnsafeRawPointer, count: Int)<br class=""><br class="">because `count` usually refers to a number of values. I think it should be:<br class=""><br class="">func copy(bytes: Int, from: UnsafeRawPointer)<br class=""></blockquote><br class="">Using `bytes` to label the count / length / size would be inconsistent with:<br class=""><br class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>Foundation.Data.init(bytes:count:)<br class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>&lt;<a href="https://developer.apple.com/reference/foundation/data/1780158-init" class="">https://developer.apple.com/reference/foundation/data/1780158-init</a>&gt;<br class=""><br class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>Foundation.Data.copyBytes(to:count:)<br class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>&lt;<a href="https://developer.apple.com/reference/foundation/data/1780297-copybytes" class="">https://developer.apple.com/reference/foundation/data/1780297-copybytes</a>&gt;<br class=""><br class="">UnsafeMutableRawPointer could use a `size` or `sizeInBytes` label.<br class="">(This also applies to the `allocate` and `deallocate` methods).<br class=""><br class="">— Ben<br class=""></blockquote><br class="">Thanks for pointing that out.<br class=""><br class="">My concern is code like:<br class=""><br class="">&nbsp;let ptrToInt: UnsafePointer&lt;Int32&gt; = …<br class="">&nbsp;rawPtr.copyBytes(from: ptrToInt, count: 4)<br class=""><br class="">which looks a lot like 4 Int32s will be copied when only 1 Int32 will actually be copied.<br class=""><br class="">Anyone care to vote on this?<br class=""></blockquote><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">I think you're being overly fussy. &nbsp;The name clearly says we're copying</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">bytes. &nbsp;count says how many. &nbsp;But if you want to avoid any possibility</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">of confusion, only support source pointers that are UnsafeRawPointer.</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""></div></blockquote><div><br class=""></div><div><br class=""></div><div class="">Thanks. I’ll take that as a +1 for the current form.</div><div class=""><br class=""></div><div class="">We support implicit argument conversion from UnsafePointer&lt;T&gt; to UnsafeRawPointer primarily so that UnsafePointers can be passed as `void*` arguments.</div><div class=""><br class=""></div><div class="">-Andy</div><div class=""><br class=""></div><blockquote type="cite" class=""><div class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class=""><br class=""><br class="">Current:<br class=""><br class="">&nbsp;let rawPtr = UnsafeMutableRawPointer.allocate(bytes: 24)<br class="">&nbsp;rawPtr.copyBytes(from: ptrToInt, count: 24)<br class="">&nbsp;rawPtr.deallocate(bytes: 24)<br class=""><br class="">Proposed:<br class=""><br class="">&nbsp;let rawPtr = UnsafeMutableRawPointer.allocate(sizeInBytes: 24)<br class="">&nbsp;rawPtr.copyBytes(from: ptrToInt, sizeInBytes: 24)<br class="">&nbsp;rawPtr.deallocate(sizeInBytes: 24)<br class=""><br class="">-Andy<br class=""></blockquote><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">--<span class="Apple-converted-space">&nbsp;</span></span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Dave</span></div></blockquote></div><br class=""></body></html>