Earlier quoted context omitted.
s2 := append(s1, x) s3 := append(s1, y) shouldn’t be allowed, because what it’s likely to do is not what anyone meant. In a pass-by-value language, passing a slice or map by value should copy it, append should be a method that returns void, and passing a pointer should be the way to share state and avoid copies.
What would you expect that code to do? I'd expect to have two different slices, s2 and s3, to contain all the same elements aside from the last. [a, b, c, x] and [a, b, c, y] and s1 remains [a, b, c]
It does exactly that, yes: https://go.dev/play/p/rs2FeK_QUjs
[a b c]
[a b c x]
[a b c y]
But maybe it doesn't: https://go.dev/play/p/Na-eL0sOV9e [a b c]
[a b c y]
So... maybe they share the same backing array? Lets try setting s2[0] to "z" after appending with the original code: https://go.dev/play/p/mAB-gUb0shB [a b c]
[z b c x]
[a b c y]
Apparently not. But also apparently yes? https://go.dev/play/p/k1ciGzyS2gc [z b c]
Let's try appending just one more item before redoing ^ that example, where they all shared the same data: https://go.dev/play/p/5JneXHMeUjx [a b c]
[z b c x x2]
[a b c y y2]
Notice that in all of these examples, I haven't explicitly declared a length or capacity. There's nothing "funny looking" or clearly intentionally allowing these different behaviors, it's just simple, very-common slice use..... so yeah. This is a source of a number of hard-to-track-down bugs.