3 ms·
On the other hand, it's very clear about what's actually happening when you delete an element of an array. I'm not a C guy, but I figure doing this in C would
by pasabagi 6y ago
On the other hand, it's very clear about what's actually happening when you delete an element of an array.
I'm not a C guy, but I figure doing this in C would involve several lines of mmemove, with loads of error checking[1]. So the Go version is about as ergonomic as you can get without obscuring what's going on.
[1] - I guess you'd do something like: memmove(a+i+1, a+i, sizeof(element) * (a->len - i)) with a whole load of checks to make sure everything's in order. I think C has the advantage of being utterly explicit about what is actually happening, but I think a higher level thing like append() is kind of nice when you don't want to think hard about, say, inserting an element in the middle of an array.