On Sat, 6 Feb 2021 at 11:25, Martin Schnabel <[email protected]> wrote: > > > > On 06.02.21 03:32, Wojciech S. Czarnecki wrote: > > Dnia 2021-02-04, o godz. 00:30:57 > > Selahaddin Harmankaya <[email protected]> napisaĆ(a): > > > >> There are obviously more things to consider > > > > Slice is not an array, it is a _view_into_ an array. Many such views > > into the same array may exist simultaneously. > > > > A "remove element from _slice_" operation always must make a new array > > and copy all elements that you intend to stay. Current idiom using append > > will do this for you while being frank about costs. > > Maybe I misunderstand what you wrote, but as long as the slice has > enough capacity the array will be reused and not not copied: > > https://play.golang.org/p/sevpWixzw6V >
Yes, given this and e.g. https://play.golang.org/p/Dyh9Dzd-1zq , in my opinion it's hard to argue against having slice manipulation primitives with clearer semantics. Having generics will allow this though! -- Arnaud -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAJ6cK1aP2XEoGFjE3j6huy9gsszQPQGk0Aa0kCZGPL2AO8z8_A%40mail.gmail.com.
