News for hackers. Stuff that matters.
Re:Go: A Surprising Edge Case Concerning Append and Slice Al... by karmakaze on Saturday May 16, 2015 @09:18AM (#9555984)
You're describing how it actually works which is by way of 'shallow value' semantics which is precisely what the commenter is against. Such semantics requires understanding implementation without a simple opaque description. Either full mutability or 'deep value' semantics is simpler. For instance if the b: = a; followed by a[0] = 2 resulted on a copy on write, then b would be unaffected after the assignment of value. Of course the language and libraries do what they do and the user must be aware. Go was supposed to be easier, so copy-on-write semantics would have made more sense.
Re:Go: A Surprising Edge Case Concerning Append and Slice Al... by a-nom-a-ly on Saturday May 16, 2015 @09:29AM (#9556012)
I'm not sure what you're trying to say. This is, IMO, nothing more than a lack of understanding. Is the result of `a := make([]struct{}, 0, 1); b := a; b = append(b, struct{}{}); println(len(a), len(b))` also surprising?