[swift-evolution] [Review] SE-0016 - Adding initializers to Int and UInt to convert from UnsafePointer and UnsafeMutablePointer
richardross at fb.com
Wed Mar 23 16:30:18 CDT 2016
Just for note, an alternative that works right now (whether intentional or not) is this:
let rawAddress: Int = UnsafeMutablePointer<UInt8>(nil).distanceTo(myPointer)
This gives the distance in bytes (so on 95% of all platforms, the raw address). It currently isn't clear that this is how you can accomplish this in swift, so I'm +1 on the proposal.
> On Mar 22, 2016, at 8:24 PM, Joseph Lord via swift-evolution <swift-evolution at swift.org> wrote:
>> On Mar 22, 2016, at 9:35 PM, Chris Lattner via swift-evolution <swift-evolution at swift.org> wrote:
>> Hello Swift community,
>> The review of "Adding initializers to Int and UInt to convert from UnsafePointer and UnsafeMutablePointer" begins now and runs through March 25th. The proposal is available here:
> I give the concept a +1. Swift should support dangerous actions but should make them clear and obvious. I do think that there is room to improve the argument label. There are two issues with "bitPattern" that concern me:
> 1) it should be clear that it will be the bitPattern of the pointer itself not whatever the pointer refers to.
> 2) it doesn't indicate the danger of using the results of this
> I don't have a great alternative to bitPattern but maybe something like: "rawMemoryAddress"
> I've read the proposal and given it a little bit of thought but have not yet read preceding or recent comments.
> swift-evolution mailing list
> swift-evolution at swift.org
More information about the swift-evolution