Errata for Swift Internals 1st Edition

Creating this topic to catch any typos and bugs in the 1st Edition of Swift Internals.

1 Like

Page 9: Should be Xcode26

Page 18: Instead let size2 = size1 should be var size2 = size1

Hi, Thank you for pointing out the typos. I have fixed them both.

Section 1.2 Anatomy of Swift Types in Memory - Enum Memory Layout

The Result enum example’s size/stride/alignment values are correct, but the explanation of how size is computed is wrong.

The book states:

Size is 8 + 8 + 1, a total of 17 bytes, with 8 for the associated value of Int, 8 for the String, and 1 for storing the tag.

In reality:

String is 16 bytes on 64-bit platforms, not 8. Enum layout uses union semantics — the size is max(associated value sizes) + discriminator, not sum + discriminator. 16 (String) + 1 (tag) = 17.

page 17 - “In Swift, by default, Classes, Actors, and escaping closures are reference types; on the other hand, Structs, Enums, functions, and non-escaping closures are value types.”
To my knowledge it’s not correct all closures are reference typed (so functions also are reference they just not anonymous). Apple stated so in the documentation Documentation

Maybe I’m wrong lets discuss