Thanks for the explanation. On Wednesday, August 9, 2017 at 11:50:57 PM UTC+12, Marvin Renich wrote: > > [I'm subscribed; reply-to set.] > > * sno <farleys...@gmail.com <javascript:>> [170808 21:34]: > > Hmm, interesting. However, wouldn't that mean that if I removed the > > function and did the following: https://play.golang.org/p/enI6UmYoFJ > the > > escape analysis wouldn't happen? > > Why would escape analysis not happen for main just like for any other > function? (main is just a function.) By passing the value of > sliceHeader.Data to fmt.Printf, the address of the backing array > allocated for the slice escapes, so it is allocated on the heap. > > And, as Jan Mercl says in another reply, the size of the backing array > allocated for a slice created from a literal is an implementation detail > that is not specified in the language spec, and so the size can vary > between invocations, including between different invocations of the > slice initialization code within the same invocation of the program > (e.g. if the slice is initialized within the body of a for loop). > > ...Marvin > >
-- 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. For more options, visit https://groups.google.com/d/optout.