[swift-evolution] [swift-evolution-announce] [Review] SE-0076: Add overrides taking an UnsafePointer source to non-destructive copying methods on UnsafeMutablePointer
Andrew Trick
atrick at apple.com
Wed May 4 12:07:56 CDT 2016
> On May 4, 2016, at 9:40 AM, Jordan Rose <jordan_rose at apple.com> wrote:
>
>>
>> On May 4, 2016, at 09:18, Joe Groff via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>>
>>>
>>> On May 3, 2016, at 9:39 PM, Andrew Trick via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>>>
>>>
>>>> On May 3, 2016, at 8:56 PM, Chris Lattner <clattner at apple.com <mailto:clattner at apple.com>> wrote:
>>>>
>>>> Hello Swift community,
>>>>
>>>> The review of "SE-0076: Add overrides taking an UnsafePointer source to non-destructive copying methods on UnsafeMutablePointer" begins now and runs through May 9. The proposal is available here:
>>>>
>>>> https://github.com/apple/swift-evolution/blob/master/proposals/0076-copying-to-unsafe-mutable-pointer-with-unsafe-pointer-source.md <https://github.com/apple/swift-evolution/blob/master/proposals/0076-copying-to-unsafe-mutable-pointer-with-unsafe-pointer-source.md>
>>>>
>>>> * What is your evaluation of the proposal?
>>>
>>> The new methods are needed, but they don’t need to be overloads. I have no idea why the argument type was originally declared Mutable.
>>>
>>> func assignBackwardFrom(source: UnsafePointer<Pointee>, count: Int
>>> )
>>>
>>> func assignFrom(source: UnsafePointer<Pointee>, count: Int
>>> )
>>>
>>> func initializeFrom(source: UnsafePointer<Pointee>, count: Int)
>>>
>>> FWIW: I made precisely this change a while back on an experimental branch while experimenting with UnsafePointer conversion. I don’t see a problem with it.
>>>
>>> Implicit argument conversion from UnsafeMutablePointer<Pointee> to UnsafePointer<Pointee> is normal and extremely obvious.
>>
>> Yeah, Andy's approach seems cleaner than overloading.
>
> :-( …but it’s an implicit conversion. Which we’re trying to expunge from the language. (Sort of.)
I’ve heard exactly the opposite argument recently. Namely that explicit UnsafePointer construction indicates an “unsafe” cast (I personally don’t agree with that argument though).
Tangential: Which of our current implicit conversions are considered bad? I can’t think of a good alternative, particularly for String/Array to UnsafePointer.
-Andy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160504/79c3baa3/attachment.html>
More information about the swift-evolution
mailing list