Hi everyone, The standard library has bitPattern initializers on pointers. But we are missing initializers to create integers from pointers.
Someone needs to propose these APIs, walk them through swift-evolution, write a patch for the library and add tests. extension UInt { init<T>(bitPattern: UnsafePointer<T>) { self = UInt(Builtin.ptrtoint_Word(bitPattern._rawValue)) } init<T>(bitPattern: UnsafeMutablePointer<T>) { self = UInt(Builtin.ptrtoint_Word(bitPattern._rawValue)) } } extension Int { init<T>(bitPattern: UnsafePointer<T>) { self = Int(Builtin.ptrtoint_Word(bitPattern._rawValue)) } init<T>(bitPattern: UnsafeMutablePointer<T>) { self = Int(Builtin.ptrtoint_Word(bitPattern._rawValue)) } } https://bugs.swift.org/browse/SR-131 Dmitri -- main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if (j){printf("%d\n",i);}}} /*Dmitri Gribenko <griboz...@gmail.com>*/ _______________________________________________ swift-dev mailing list swift-dev@swift.org https://lists.swift.org/mailman/listinfo/swift-dev