[swift-evolution] Why hard-code octet-sized bytes?

Chris Lattner clattner at apple.com
Sun Jun 19 00:04:23 CDT 2016


> On Jun 17, 2016, at 1:01 PM, Daryle Walker via swift-evolution <swift-evolution at swift.org> wrote:
> 
> When I first looked into Swift, I noticed that the base type was called “UInt8” (and “Int8”) and not something like “Byte.”  I know modern computers have followed the bog standard 8/16/32(/64) architecture for decades, but why hard code it into the language/library?  Why should 36-bit processors with 9-bit bytes, or processors that start at 16 bits, be excluded right off the bat?  Did you guys see a problem with how (Objective-)C(++) had to define its base types in a mushy way to accommodate the possibility non-octet bytes?

Given that there are no 9-bit byte targets supported by Swift (or LLVM), it would be impossible to test that configuration, and it is well known that untested code doesn’t work.  As such, introducing a Byte type which is potentially not 8 bits in size would only add cognitive overload.  Any promised portability benefit would simply mislead people.

-Chris 



More information about the swift-evolution mailing list