<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 May 9, 2016, at 1:23 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="">Along similar lines, with the indexing model change, isn't the following outdated?</div></div></blockquote><div><br class=""></div>Yes. Thanks. I’m working on updating both the proposal and implementation.</div><div>-Andy</div><div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><br class=""></div><div class="">```</div><div class=""><pre style="white-space:pre-wrap;color:rgb(51,51,51);font-family:Consolas,&quot;Liberation Mono&quot;,Menlo,Courier,monospace;font-size:14px;margin-top:0px;margin-bottom:0px;line-height:1.45;padding:16px;overflow:auto;border-radius:3px;word-wrap:normal;background-color:rgb(247,247,247)" class=""><span style="color:rgb(167,29,93)" class="">extension</span> UnsafeBytePointer <span style="color:rgb(167,29,93)" class="">:</span> RandomAccessIndex {
  <span style="color:rgb(167,29,93)" class="">typealias</span> Distance <span style="color:rgb(167,29,93)" class="">=</span> <span style="color:rgb(0,134,179)" class="">Int</span>

  <span style="color:rgb(167,29,93)" class="">func</span> <span style="color:rgb(121,93,163)" class="">successor</span>() <span style="color:rgb(167,29,93)" class="">-&gt;</span> UnsafeBytePointer
  <span style="color:rgb(167,29,93)" class="">func</span> <span style="color:rgb(121,93,163)" class="">predecessor</span>() <span style="color:rgb(167,29,93)" class="">-&gt;</span> UnsafeBytePointer
  <span style="color:rgb(167,29,93)" class="">func</span> <span style="color:rgb(121,93,163)" class="">distance</span>(to <span style="color:rgb(167,29,93)" class="">:</span> UnsafeBytePointer) <span style="color:rgb(167,29,93)" class="">-&gt;</span> <span style="color:rgb(0,134,179)" class="">Int</span>
  <span style="color:rgb(167,29,93)" class="">func</span> <span style="color:rgb(121,93,163)" class="">advanced</span>(by <span style="color:rgb(167,29,93)" class="">:</span> <span style="color:rgb(0,134,179)" class="">Int</span>) <span style="color:rgb(167,29,93)" class="">-&gt;</span> UnsafeBytePointer
}
</pre></div><div class="">```</div><div class="gmail_extra"><br class=""></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Mon, May 9, 2016 at 3:20 PM, Joe Groff via swift-evolution <span dir="ltr" class="">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</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="">Regarding the UnsafeBytePointer API:<span class=""><div class=""><br class=""></div><div class=""><pre style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:14px;margin-top:0px;margin-bottom:0px;line-height:1.45;padding:16px;overflow:auto;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-wrap:normal;word-break:normal" class=""></pre></div><blockquote type="cite" class=""><div class=""><pre style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:14px;margin-top:0px;margin-bottom:0px;line-height:1.45;padding:16px;overflow:auto;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-wrap:normal;word-break:normal" class=""><span style="color:rgb(167,29,93)" class="">struct</span> UnsafeBytePointer <span style="color:rgb(167,29,93)" class="">:</span> <span style="color:rgb(0,134,179)" class="">Hashable</span>, _Pointer {

  <span style="color:rgb(167,29,93)" class="">let</span> _rawValue: Builtin<span style="color:rgb(167,29,93)" class="">.</span>RawPointer

  <span style="color:rgb(167,29,93)" class="">var</span> hashValue: <span style="color:rgb(0,134,179)" class="">Int</span> {<span style="color:rgb(167,29,93)" class="">...</span>}

  <span style="color:rgb(167,29,93)" class="">init</span><span style="color:rgb(167,29,93)" class="">&lt;</span>T<span style="color:rgb(167,29,93)" class="">&gt;</span>(_ <span style="color:rgb(167,29,93)" class="">:</span> <span style="color:rgb(0,134,179)" class="">UnsafePointer</span><span style="color:rgb(167,29,93)" class="">&lt;</span>T<span style="color:rgb(167,29,93)" class="">&gt;</span>)
  <span style="color:rgb(167,29,93)" class="">init</span><span style="color:rgb(167,29,93)" class="">&lt;</span>T<span style="color:rgb(167,29,93)" class="">&gt;</span>(_ <span style="color:rgb(167,29,93)" class="">:</span> <span style="color:rgb(0,134,179)" class="">UnsafeMutablePointer</span><span style="color:rgb(167,29,93)" class="">&lt;</span>T<span style="color:rgb(167,29,93)" class="">&gt;</span>)
  <span style="color:rgb(167,29,93)" class="">init</span>?<span style="color:rgb(167,29,93)" class="">&lt;</span>T<span style="color:rgb(167,29,93)" class="">&gt;</span>(_ <span style="color:rgb(167,29,93)" class="">:</span> <span style="color:rgb(0,134,179)" class="">UnsafePointer</span><span style="color:rgb(167,29,93)" class="">&lt;</span>T<span style="color:rgb(167,29,93)" class="">&gt;</span>?)
  <span style="color:rgb(167,29,93)" class="">init</span>?<span style="color:rgb(167,29,93)" class="">&lt;</span>T<span style="color:rgb(167,29,93)" class="">&gt;</span>(_ <span style="color:rgb(167,29,93)" class="">:</span> <span style="color:rgb(0,134,179)" class="">UnsafeMutablePointer</span><span style="color:rgb(167,29,93)" class="">&lt;</span>T<span style="color:rgb(167,29,93)" class="">&gt;</span>?)

  <span style="color:rgb(167,29,93)" class="">init</span><span style="color:rgb(167,29,93)" class="">&lt;</span>T<span style="color:rgb(167,29,93)" class="">&gt;</span>(_ <span style="color:rgb(167,29,93)" class="">:</span> OpaquePointer<span style="color:rgb(167,29,93)" class="">&lt;</span>T<span style="color:rgb(167,29,93)" class="">&gt;</span>)
  <span style="color:rgb(167,29,93)" class="">init</span>?<span style="color:rgb(167,29,93)" class="">&lt;</span>T<span style="color:rgb(167,29,93)" class="">&gt;</span>(_ <span style="color:rgb(167,29,93)" class="">:</span> OpaquePointer<span style="color:rgb(167,29,93)" class="">&lt;</span>T<span style="color:rgb(167,29,93)" class="">&gt;</span>?)

  <span style="color:rgb(167,29,93)" class="">init</span>?(bitPattern: <span style="color:rgb(0,134,179)" class="">Int</span>)
  <span style="color:rgb(167,29,93)" class="">init</span>?(bitPattern: <span style="color:rgb(0,134,179)" class="">UInt</span>)

  <span style="color:rgb(167,29,93)" class="">func</span> <span style="color:rgb(121,93,163)" class="">load</span>&lt;T&gt;(_ <span style="color:rgb(167,29,93)" class="">:</span> T<span style="color:rgb(167,29,93)" class="">.</span><span style="color:rgb(167,29,93)" class="">Type</span>) <span style="color:rgb(167,29,93)" class="">-&gt;</span> T

  <span style="color:rgb(167,29,93)" class="">@warn_unused_result</span>
  <span style="color:rgb(167,29,93)" class="">init</span>(allocatingBytes size: <span style="color:rgb(0,134,179)" class="">Int</span>, alignedTo: <span style="color:rgb(0,134,179)" class="">Int</span>)

  <span style="color:rgb(167,29,93)" class="">@warn_unused_result</span>
  <span style="color:rgb(167,29,93)" class="">init</span><span style="color:rgb(167,29,93)" class="">&lt;</span>T<span style="color:rgb(167,29,93)" class="">&gt;</span>(allocatingCapacity count: <span style="color:rgb(0,134,179)" class="">Int</span>, of: T<span style="color:rgb(167,29,93)" class="">.</span><span style="color:rgb(167,29,93)" class="">Type</span>)

  <span style="color:rgb(167,29,93)" class="">func</span> <span style="color:rgb(121,93,163)" class="">deallocateBytes</span>(<span style="color:rgb(121,93,163)" class="">_</span> <span class="">size</span>: <span style="color:rgb(0,134,179)" class="">Int</span>, alignedTo: <span style="color:rgb(0,134,179)" class="">Int</span>)

  <span style="color:rgb(167,29,93)" class="">func</span> <span style="color:rgb(121,93,163)" class="">deallocateCapacity</span>&lt;T&gt;(<span style="color:rgb(121,93,163)" class="">_</span> <span class="">num</span>: <span style="color:rgb(0,134,179)" class="">Int</span>, of: T<span style="color:rgb(167,29,93)" class="">.</span><span style="color:rgb(167,29,93)" class="">Type</span>)

  <span style="color:rgb(150,152,150)" class="">// Returns a pointer one byte after the initialized memory.</span>
  <span style="color:rgb(167,29,93)" class="">func</span> <span style="color:rgb(121,93,163)" class="">initialize</span>&lt;T&gt;(<span style="color:rgb(121,93,163)" class="">with</span> <span class="">newValue</span>: T, count: <span style="color:rgb(0,134,179)" class="">Int</span> <span style="color:rgb(167,29,93)" class="">=</span> <span style="color:rgb(0,134,179)" class="">1</span>) <span style="color:rgb(167,29,93)" class="">-&gt;</span> UnsafeBytePointer

  <span style="color:rgb(150,152,150)" class="">// Returns a pointer one byte after the initialized memory.</span>
  <span style="color:rgb(167,29,93)" class="">func</span> <span style="color:rgb(121,93,163)" class="">initialize</span>&lt;T&gt;(from: <span style="color:rgb(0,134,179)" class="">UnsafePointer</span><span style="color:rgb(167,29,93)" class="">&lt;</span>T<span style="color:rgb(167,29,93)" class="">&gt;</span>, count: <span style="color:rgb(0,134,179)" class="">Int</span>) <span style="color:rgb(167,29,93)" class="">-&gt;</span> UnsafeBytePointer

  <span style="color:rgb(167,29,93)" class="">func</span> <span style="color:rgb(121,93,163)" class="">initializeBackward</span>&lt;T&gt;(<span style="color:rgb(121,93,163)" class="">from</span> <span class="">source</span>: <span style="color:rgb(0,134,179)" class="">UnsafePointer</span><span style="color:rgb(167,29,93)" class="">&lt;</span>T<span style="color:rgb(167,29,93)" class="">&gt;</span>, count: <span style="color:rgb(0,134,179)" class="">Int</span>)

  <span style="color:rgb(167,29,93)" class="">func</span> <span style="color:rgb(121,93,163)" class="">deinitialize</span>&lt;T&gt;(_ <span style="color:rgb(167,29,93)" class="">:</span> T<span style="color:rgb(167,29,93)" class="">.</span><span style="color:rgb(167,29,93)" class="">Type</span>, count: <span style="color:rgb(0,134,179)" class="">Int</span> <span style="color:rgb(167,29,93)" class="">=</span> <span style="color:rgb(0,134,179)" class="">1</span>)
}
</pre></div></blockquote><div class=""><br class=""></div></span><div class="">Should we also have 'assign' methods, matching 'initialize'? Should 'deinitialize' be called 'destroy', matching 'UnsafeMutablePointer's API?</div><div class=""><br class=""></div><div class="">-Joe</div></div><br class="">_______________________________________________<br class="">
swift-evolution mailing list<br class="">
<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="">
<br class=""></blockquote></div><br class=""></div></div>
</div></blockquote></div><br class=""></body></html>