> On Apr 28, 2016, at 11:10 AM, Chris Lattner <[email protected]> wrote:
> 
> Hello Swift community,
> 
> The review of "SE-0017: Change Unmanaged to use UnsafePointer" begins now and 
> runs through May 3. The proposal is available here:
> 
>       
> https://github.com/apple/swift-evolution/blob/master/proposals/0017-convert-unmanaged-to-use-unsafepointer.md


I have some concerns, but let me just suggest a simple alternative and see what 
people think...

- Leave the existing from/toOpaque API until we can come up with a better plan 
for moving away from OpaquePointer.

- Add initializers to avoid boilerplate, but only for "safe" variants of the 
cast:

extension Unmanaged {
  @_transparent
  public init(_ from : UnsafePointer<Instance>)

  @_transparent
  public init?(_ from : UnsafePointer<Instance>?)
}

extension UnsafeMutablePointer where Pointee : AnyObject {
  @_transparent
  public init(_ from : Unmanaged<Pointee>)

  @_transparent
  public init?(_ from : Unmanaged<Pointee>?)
}

- This doesn't solve the stated problem of passing unmanaged pointers to 
'void*' imports. Is that really an issue? I believe the correct fix is to stop 
importing 'void*' as UnsafePointer<Void>. We should have a nominally distinct 
"opaque" pointer type, 'void*' should be imported as that type, and casting 
from any UnsafePointer to the opaque pointer type should be inferred and 
implicit for function arguments. I can send a proposal for eliminating 
UnsafePointer<Void> next week, but the scope of that proposal will be much 
broader.

-Andy
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to