[swift-evolution] [swift-evolution-announce] SE-0138 UnsafeBytes

Rien Rien at Balancingrock.nl
Sat Sep 3 01:35:42 CDT 2016

> On 02 Sep 2016, at 22:34, Tony Parker via swift-evolution <swift-evolution at swift.org> wrote:
> I would instead prefer to look at what we can do with adding API to the existing types to cover this use case. You point out in the proposal that it has become customary to use [UInt8] in API. I would prefer that we work towards a solution that makes it customary to use Data when you want to expose an API that uses Data. 

I support that sentiment. We should stick with existing solutions and not dilute them without reason.

Having said that, my personal experience with NSData is pretty bad. It never really fits my needs unless I am dealing with amorphous data that stay’s amorphous.
As soon as I need to figure out what is in the data, the code gets ugly fast and needs extensive commenting to stay maintainable (and we all know what happens with comments…)

I think Andy is right, and we need to differentiate between byte access and amorphous data blocks.

A minor point: many programmers new to the platform will know what to do with pointers, Data on the other hand is too much of an abstraction to grasp intuitively.

And a minor-minor point: Personally I hate the “Unsafe” part in the name. Seems a bit pedantic to me. I do not need subjective judgements in a language. (Is there really a SW-engineer out there that does not know about the inherent dangers of direct memory access?, does “unsafe” really add value to the language?)


More information about the swift-evolution mailing list