[swift-evolution] Unmanaged, and COpaquePointer vs. Unsafe(Mutable)Pointer
jtbandes at gmail.com
Tue Dec 8 02:26:30 CST 2015
One hopes to avoid COpaquePointer and Unsafe(Mutable)Pointer, but in
practice I've had occasion to use them a few times.
Things that are nice:
- Unmanaged.passUnretained/takeRetained/etc. which make memory management
Things I've been frustrated by:
- An API takes UnsafeMutablePointer<Void>, but Unmanaged.toOpaque() returns
- An API gives me UnsafeMutablePointer<Void>, but Unmanaged.fromOpaque()
takes a COpaquePointer.
In practice, I end up with monstrosities like:
I think a few things could help:
- Phase out COpaquePointer in favor of UnsafePointer<Void> (is this already
- Add implicit conversion from COpaquePointer to
Unsafe(Mutable)Pointer<Void>, and/or vice versa.
- Even better, add implicit conversion from Unmanaged<T> to COpaquePointer
or UnsafePointer<Void>, behaving the way toOpaque() currently does. Also,
replace Unmanaged.fromOpaque() with an initializer Unmanaged(_:
What are others' experiences? Would it be feasible/favorable to have some
of these conversions?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution