3 ms·
What is the advantage of this design? Its disadvantages are quite obvious, but what use case do they buy? It would be a different story if append() always retu
by int_19h 5y ago
What is the advantage of this design? Its disadvantages are quite obvious, but what use case do they buy?
It would be a different story if append() always returned a new slice and never updated the original data - then, yes, having to assign is the price you pay for immutability and its benefits (as in e.g. F# or Clojure).
But this is not the case here - it's the way it is simply because Go designers didn't see it fit to have a proper abstraction for a dynamically resizable list, and punted it all down to slices (a lower-level abstraction) instead, which the users are then expected to apply in correct order.