News for hackers. Stuff that matters.
Re:Go says Wat by TheDong on Friday September 07, 2018 @04:11PM (#17937291)
> Whether you create multiple views in the array, mutate the views

Whether there are multiple views or not is actually an implementation detail, and whether "append" chooses to allocate memory or not will change whether there are multiple copies or multiple views of the array.

All of that behavior is something you absolutely cannot rely on.

Re:Go says Wat by kodablah on Friday September 07, 2018 @04:18PM (#17937324)
Can I not rely on append only allocating when the values to append won't fit in the remaining capacity of the underlying array starting from the end of the slice? Some articles indicate this and definitely don't seem surprising [0]. Granted I don't know the implementation details, but how do copies of the array or numbers of slices of the array affect that? Regardless, with Go as opposed to lower level languages, building reliance on whether functions do memory allocation (even built in ones) is folly.

0 - https://blog.golang.org/go-slices-usage-and-internals

Re:Go says Wat by slrz on Saturday September 08, 2018 @11:10AM (#17941131)
The behaviour of append and the conditions where it will allocate a new backing array are specified and part of the language. Implementation details don't even enter the picture here. You can absolutely rely on that not changing.