[swift-evolution] Proposal: [stdlib] Remove withUnsafe[Mutable]Pointer[s]()

Joe Groff jgroff at apple.com
Wed Dec 16 15:53:19 CST 2015

> On Dec 16, 2015, at 1:51 PM, Kevin Ballard <kevin at sb.org> wrote:
> On Wed, Dec 16, 2015, at 01:38 PM, Joe Groff wrote:
>> The pointer conversions are already poorly discoverable, and people don't know they exist since code completion doesn't make it apparent. Showing the APIs as overloaded taking 'inout's or something similar would make it more apparent how you can use them.
> I'm hoping that adding documentation to UnsafePointer/UnsafeMutablePointer that mentions the conversions will help a lot, and ideally the book would mention this too (presumably as a note in the section on in-out parameters). If I didn't already know about the conversion and I encountered a function expecting an UnsafePointer/UnsafeMutablePointer, my first inclination is to type "UnsafePointer" (or "UnsafeMutablePointer") into the documentation browser and read the results. This is why I don't like withUnsafe[Mutable]Pointer[s]() existing, because it makes people think that's what you have to use, when in most cases the &x conversion is simpler.

They are documented fairly extensively in "Using Swift with Cocoa and Objective-C" (since they exist to interop with C):

https://developer.apple.com/library/ios/documentation/Swift/Conceptual/BuildingCocoaApps/InteractingWithCAPIs.html#//apple_ref/doc/uid/TP40014216-CH8-ID17 <https://developer.apple.com/library/ios/documentation/Swift/Conceptual/BuildingCocoaApps/InteractingWithCAPIs.html#//apple_ref/doc/uid/TP40014216-CH8-ID17>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151216/c18501a2/attachment.html>

More information about the swift-evolution mailing list