On Wed, Dec 16, 2015, at 12:12 AM, Dave Abrahams wrote: > > > Come to think of it, what's the actual use-case for withUnsafePointer()? > > I'm not sure we still have one that isn't covered by &x; that's my point. > > > If a value is mutable, you can already use &x or > > withUnsafeMutablePointer(), and if it's immutable, you can't call > > withUnsafePointer() today anyway. The proposed change would just make > > withUnsafePointer() into the equivalent of `var x = value; > > callSomethingWith(&x)`. The only reason to really want a > > withUnsafePointer() function is if it can give you an UnsafePointer to an > > immutable value without copying it, but we can't do that. I'm inclined to > > say we should just get rid of withUnsafePointer() entirely, at least until > > such time as Swift has a way to pass immutable values by-ref. > > I'm inclined to agree. Proposal?
Sure, I'll write one up. I suspect that withUnsafePointer() / withUnsafeMutablePointer() are likely to be rarely used today, and most uses can probably be trivially replaced with just passing a &x ref, so this shouldn't be a big deal. I'll also go ahead and write up one suggesting that we should allow for using &x when x is immutable when passing a parameter to a function that takes UnsafePointer. -Kevin Ballard _______________________________________________ swift-dev mailing list swift-dev@swift.org https://lists.swift.org/mailman/listinfo/swift-dev