[swift-evolution] Unmanaged, and COpaquePointer vs. Unsafe(Mutable)Pointer

Jacob Bandes-Storch jtbandes at gmail.com
Tue Dec 8 22:07:23 CST 2015


Proposed: https://github.com/apple/swift-evolution/pull/44

Jacob

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.)
>
> Jordan
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151208/ef3f3cd6/attachment.html>


More information about the swift-evolution mailing list