Why will RawByte be deprecated in Swift 3?


(Marco Masser) #1

There’s a RawByte struct in the Swift 2.2 standard library:

/// A byte-sized thing that isn't designed to interoperate with
/// any other types; it makes a decent parameter to
/// `UnsafeMutablePointer<Memory>` when you just want to do bytewise
/// pointer arithmetic.
@available(*, deprecated, message="it will be removed in Swift 3")
public struct RawByte {
}

Why is that deprecated? On the current Swift master branch (22c4d7d) it’s still used in the String-related code and there’s also no mention about it being deprecated. Is there a replacement for RawByte? Should I just write my own version when I don’t want Int8 or UInt8 to mean “just a byte”?

Bonus question: Where does this deprecation come from? How can something be deprecated in the public Swift release when it’s not deprecated in the Swift source?

Cheers,

Marco


(Dmitri Gribenko) #2

There’s a RawByte struct in the Swift 2.2 standard library:

/// A byte-sized thing that isn't designed to interoperate with
/// any other types; it makes a decent parameter to
/// `UnsafeMutablePointer<Memory>` when you just want to do bytewise
/// pointer arithmetic.
@available(*, deprecated, message="it will be removed in Swift 3")
public struct RawByte {
}

Why is that deprecated? On the current Swift master branch (22c4d7d) it’s
still used in the String-related code and there’s also no mention about it
being deprecated. Is there a replacement for RawByte? Should I just write my
own version when I don’t want Int8 or UInt8 to mean “just a byte”?

Using UInt8 or Int8 is recommended.

Bonus question: Where does this deprecation come from? How can something be
deprecated in the public Swift release when it’s not deprecated in the Swift
source?

It comes from a preview implementation of SE-0006
https://github.com/apple/swift-evolution/blob/master/proposals/0006-apply-api-guidelines-to-the-standard-library.md

Dmitri

···

On Fri, Feb 12, 2016 at 2:34 AM, Marco Masser via swift-users <swift-users@swift.org> wrote:

--
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 <gribozavr@gmail.com>*/


(Marco Masser) #3

There’s a RawByte struct in the Swift 2.2 standard library:

/// A byte-sized thing that isn't designed to interoperate with
/// any other types; it makes a decent parameter to
/// `UnsafeMutablePointer<Memory>` when you just want to do bytewise
/// pointer arithmetic.
@available(*, deprecated, message="it will be removed in Swift 3")
public struct RawByte {
}

Why is that deprecated? On the current Swift master branch (22c4d7d) it’s
still used in the String-related code and there’s also no mention about it
being deprecated. Is there a replacement for RawByte? Should I just write my
own version when I don’t want Int8 or UInt8 to mean “just a byte”?

Using UInt8 or Int8 is recommended.

OK, I settled on typealias Byte = UInt8 within my Socket type, so it’s Socket.Byte now.

Bonus question: Where does this deprecation come from? How can something be
deprecated in the public Swift release when it’s not deprecated in the Swift
source?

It comes from a preview implementation of SE-0006
https://github.com/apple/swift-evolution/blob/master/proposals/0006-apply-api-guidelines-to-the-standard-library.md

Ah, missed that one in the diffs. Thanks for pointing it out.

Cheers,

Marco

···

On 2016-02-13, at 05:38, Dmitri Gribenko <gribozavr@gmail.com> wrote:
On Fri, Feb 12, 2016 at 2:34 AM, Marco Masser via swift-users > <swift-users@swift.org> wrote: