A bit of attention has been directed at slices recently, with a few high profile blogs shining a healthy light on them (they can be traps for young players!)
I'm a bit confused about SliceHeader as found in the reflect package (https://github.com/golang/go/blob/master/src/reflect/value.go#L1986). The comment in the code, and in the documentation at https://golang.org/pkg/reflect/#SliceHeader says SliceHeader is the runtime representation of a slice. It cannot be used safely or portably and its representation may change in a later release. Moreover, the Data field is not sufficient to guarantee the data it references will not be garbage collected, so programs must keep a separate, correctly typed pointer to the underlying data. My confusion is this, the comment says (very clearly) It's not safe, nor portable, and may change (although I have had it pointed out to me that the comparability guarantee may contradict this) Further the Data field reference won't stop the Garbage collector removing the data So, can someone explain to me what it's purpose in life is (there's suggestion that it was a temporary fix that, like all things temporary, has become permanent, and if so, I wonder if that means the documentation needs updating) This seems to me to be the better solution (but it's still in the pipeline?) https://github.com/golang/go/issues/19367 an unsafe, rather than reflect, access to the slice structure, which allows a user to do.. interesting things to the object. Am I correct in thinking that this change (when implemented) removes the reflect implementations, and does away with the comments? -- 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/669b67cd-6336-49ae-be04-4eade048b84an%40googlegroups.com.