You said: 

> I was trying around with arrays and generics because slices are more 
> complex to reason about than arrays. For example, I introduced bugs into my 
> code by not being fully aware of slices overwriting original data when you 
> append to them and the capacity is not set correctly. So, when writing 
> critical code it could be safer to avoid slices if possible for 
> this reason. Another example:
>

In my experience, you either have a fixed array size in mind to begin with 
(as in a fixed array size in a struct for padding or matching a fixed size 
C array) or you should be using a slice anyway. 

The trouble mostly comes when you keep the array around after making a 
slice of it. If you are  going to be doing *any* manipulation of a slice, 
abandoning the underlying array and only carrying around slices gets rid of 
most such errors. A slice already IS effectively an 'array, generic on 
size.'

-- 
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 golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/08fe15f5-dff1-4651-b824-86266b3ce50bn%40googlegroups.com.

Reply via email to