|
|
|
|
|
by masklinn
1748 days ago
|
|
> Go tells you very explicitly how it resizes slices by forcing you to write this: No, what most readers intuit from that is that `append` performs no mutation and that this is fine: s2 := append(s1, item)
because it looks very much like, say, (def s2 (conj s1 item))
and often it will look like it works, especially at the smaller sizes, or if you never modify (or even use) s1.Except it's absolutely not fine. That's why other language separate slices and vectors and avoid confusing two objects which have different behaviours and uses even if their representation is very similar. |
|
> other language separate slices and vectors
Go has a separate type for arrays, which is a value type