[swift-evolution] Unmanaged, and COpaquePointer vs. Unsafe(Mutable)Pointer
jtbandes at gmail.com
Tue Dec 8 22:07:23 CST 2015
On Tue, Dec 8, 2015 at 4:30 PM, Jordan Rose <jordan_rose at apple.com> wrote:
> On Dec 8, 2015, at 16:03, Jacob Bandes-Storch <jtbandes at gmail.com> wrote:
> Thanks, Jordan. I'll write one up tonight.
> Should it use UnsafePointer or UnsafeMutablePointer? I've seen that C
> APIs frequently get imported as UnsafeMutablePointer, when it doesn't
> necessarily match the semantics of the API. Is that just the default?
> Either way we're going to lose in some cases. We can probably make the
> "from" case work for either, but I think the "to" case should just use
> UnsafeMutablePointer, because (a) "void *" is more common than "const void
> *" in C APIs*, and (b) if you *do* need to convert, "UnsafePointer(...)"
> is shorter. :-)
> * citation needed
> (Swift does support overloading on return type, but the downside is you
> need to always provide context, which makes it harder to break things up
> into multiple statements. So we generally avoid it unless there's a
> compelling reason.)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution