<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jul 18, 2017 at 5:20 PM, Taylor Swift <span dir="ltr"><<a href="mailto:kelvin13ma@gmail.com" target="_blank">kelvin13ma@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">No, I just forgot about the compiler subtyping relationship. Never mind that part then lol<br></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jul 18, 2017 at 4:40 PM, Andrew Trick <span dir="ltr"><<a href="mailto:atrick@apple.com" target="_blank">atrick@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><br><div><blockquote type="cite"><span><div>On Jul 18, 2017, at 11:36 AM, Taylor Swift <<a href="mailto:kelvin13ma@gmail.com" target="_blank">kelvin13ma@gmail.com</a>> wrote:</div><br class="m_1370454501932031536m_-8012624455174603415Apple-interchange-newline"></span><span><div><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><div>I'm not sure removing the need for implicit casts is a goal. I did</div><div>that with the pointer `init` methods, but now I think that should be</div><div>cleaned up to reduce API surface. I think smaller API surface wins in</div><div>these cases. Is there a usability issue you're solving?</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"><br></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">Yes, I can imagine initializing a mutable pointer to some values, and then wanting to use that pointer as a source to initialize more buffers. Having to convert a mutable pointer to an immutable pointer is annoying because a function that takes an immutable pointer obviously shouldn’t care if the pointer could be mutated anyway. It’s like having to rebind a `<span style="font-family:monospace,monospace">var</span>` variable to a `<span style="font-family:monospace,monospace">let</span>` constant before passing it as any non-<span style="font-family:monospace,monospace">inout</span><span class="m_1370454501932031536m_-8012624455174603415Apple-converted-space"> </span>argument to a function, since function parameters are immutable. At any rate, this only applies to two out of the seven memorystate operations, so comparably, it’s not a big API expansion at all.</div></div></span></blockquote><br></div><div>The conversion you’re talking about should be handled by the compiler.</div><div><br></div><div><div>public func get<T>(_ p: UnsafePointer<T>) -> T {</div><div> return p.pointee</div><div>}</div><div><br></div><div>public func foo<T>(p: UnsafeMutablePointer<T>) {</div><div> _ = get(p)</div><div>}</div><div><br></div><div>Or are you thinking of a different use case?</div><div><br></div><div>-Andy</div></div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div><div class="gmail_extra">It doesn’t look like there’s an equivalent subtyping relationship between UnsafeMutableBufferPointer and UnsafeBufferPointer like there is between the plain pointers. I agree this should be solved in the compiler.<br></div></div>