Hi Rick,

My understanding on this is that withUnsafePointer() requires an inout argument 
because it has to take a reference to the variable in order to be able to 
derive its pointer. The languages requires inout arguments to be vars, leading 
to withUnsafePointer() requiring the passed object to be a var.

There may be other subtleties I'm not aware of, though.

> Le 27 avr. 2017 à 02:42, Rick Mann via swift-users <swift-users@swift.org> a 
> écrit :
> 
> We have withUnsafePointer(to:) and withUnsafeMutablePointer(to:). Why does 
> the first take an inout parameter? The function names imply that the first 
> will not modify the pointer (which I take to mean its contents), and it makes 
> it quite clunky to pass in constant things.
> 
> -- 
> Rick Mann
> rm...@latencyzero.com
> 
> 
> _______________________________________________
> swift-users mailing list
> swift-users@swift.org
> https://lists.swift.org/mailman/listinfo/swift-users

-- 
Florent Bruneau

_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Reply via email to