Re: [swift-evolution] [Review] SE-0016 - Adding initializers to Int and UInt to convert from UnsafePointer and UnsafeMutablePointer

2016-03-28 Thread Dan Raviv via swift-evolution
On Tue, Mar 22, 2016 at 11:35 PM, Chris Lattner via swift-evolution < swift-evolution@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 i

Re: [swift-evolution] [Review] SE-0016 - Adding initializers to Int and UInt to convert from UnsafePointer and UnsafeMutablePointer

2016-03-28 Thread Russ Bishop via swift-evolution
One of the alternatives discussed in the proposal was adding mathematical operators to UnsafePointer so you can manipulate the pointers directly, such as XORing them, checking alignment, etc. I would very much prefer that we add operators and functions to UnsafePointer to express intent. Conve

Re: [swift-evolution] [Review] SE-0016 - Adding initializers to Int and UInt to convert from UnsafePointer and UnsafeMutablePointer

2016-03-28 Thread Jordan Rose via swift-evolution
I'm not sure what you mean by "the operator approach". Do you mean measuring the distance between a pointer and nil? That assumes that nil's representation is 0 (which admittedly it is on all our platforms, but which shouldn't really be in anyone's mental model of UnsafePointer). I'd like to no

Re: [swift-evolution] [Review] SE-0016 - Adding initializers to Int and UInt to convert from UnsafePointer and UnsafeMutablePointer

2016-03-28 Thread Jordan Rose via swift-evolution
> On Mar 28, 2016, at 4:47, fukurokujo via swift-evolution > wrote: > >> * What is your evaluation of the proposal? > > -1 > >> * Is the problem being addressed significant enough to warrant a change to >> Swift? > > No `UnsafePointer` and `UnsafeMutablePointer` already provide their addres

Re: [swift-evolution] [Review] SE-0016 - Adding initializers to Int and UInt to convert from UnsafePointer and UnsafeMutablePointer

2016-03-27 Thread Russ Bishop via swift-evolution
Thinking through this proposal, I really favor the operator approach rather than adding these conversions so my vote is -1. (If you really know what you're doing you can already do an unsafeBitCast so this isn't a problem I've had in the real world) >Because some of these operations are defined

Re: [swift-evolution] [Review] SE-0016 - Adding initializers to Int and UInt to convert from UnsafePointer and UnsafeMutablePointer

2016-03-25 Thread Dave Abrahams via swift-evolution
on Thu Mar 24 2016, Guillaume Lessard wrote: >> * What is your evaluation of the proposal? > > I support this. Currently this requires the use of unsafeBitCast, which works > okay but is unwieldy. > I used unsafeBitCast to implement tagged pointers in a previous > exploratory project, and I thi

Re: [swift-evolution] [Review] SE-0016 - Adding initializers to Int and UInt to convert from UnsafePointer and UnsafeMutablePointer

2016-03-24 Thread Guillaume Lessard via swift-evolution
> * What is your evaluation of the proposal? I support this. Currently this requires the use of unsafeBitCast, which works okay but is unwieldy. I used unsafeBitCast to implement tagged pointers in a previous exploratory project, and I think this proposal would improve readability without being

Re: [swift-evolution] [Review] SE-0016 - Adding initializers to Int and UInt to convert from UnsafePointer and UnsafeMutablePointer

2016-03-23 Thread Richard Ross via swift-evolution
Just for note, an alternative that works right now (whether intentional or not) is this: let rawAddress: Int = UnsafeMutablePointer(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 accomp

Re: [swift-evolution] [Review] SE-0016 - Adding initializers to Int and UInt to convert from UnsafePointer and UnsafeMutablePointer

2016-03-22 Thread Joseph Lord via swift-evolution
> On Mar 22, 2016, at 9:35 PM, Chris Lattner via swift-evolution > 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: > >

Re: [swift-evolution] [Review] SE-0016 - Adding initializers to Int and UInt to convert from UnsafePointer and UnsafeMutablePointer

2016-03-22 Thread Daniel Vollmer via swift-evolution
> * What is your evaluation of the proposal? +1 > * Is the problem being addressed significant enough to warrant a change > to Swift? Yes, the current-state leaves one unable to do certain things in pure Swift (e.g. tagged pointers) that are clearly useful on occasion. > * D