Question about CoW on value type

What do you think about having an FAQ on the official Swift.org site for these kinds of matters? Here are some other related points of confusion I've seen a fair amount (on these forums, StackOverflow, and elsewhere):

  1. Not all structs have CoW magically implemented for them.
  2. It's possible for classes to have value semantics, and structs can have value semantics
  3. Common misconception: Structs are allocated on the stack, and class objects are allocated on the heap (the C# world struggles with this confusion too, see 1, 2)
  4. People often try to inspect the "address of a struct" as a proxy for some kind of stable identity (which they don't actually have)
  5. The difference between passing a reference by value (i.e. passing an instance of an object) vs passing a reference by reference (inout)
  6. and more?

(Wouldn't it be ironic if I made mistakes in laying out these common misconceptions? :sweat_smile:)

2 Likes