On Sat, Jul 8, 2017 at 7:37 PM, Ian Lance Taylor <i...@golang.org> wrote:
> On Sat, Jul 8, 2017 at 6:59 PM, Santhosh Ram Manohar > <santhosh....@gmail.com> wrote: > > > > On Saturday, July 8, 2017 at 4:09:32 PM UTC-7, Dave Cheney wrote: > >> > >> An array is a vector of values in memory. A slice is a small struct that > >> describes an array stored elsewhere in memory. > > > > > > I understand the slice vs array difference. But in this statement, > > > > intPtr := (*[]byte)(p) > > > > my interpretation was intPtr is a pointer to a slice of bytes and slice's > > underlying array reference is the 4 bytes of the integer, isn't it ? > > A slice is not a backing array. A pointer to a slice is not a pointer > to the slice's backing array. > So in this case, a pointer to 4 bytes of memory is being interpreted as pointer to a slice. When the slice is referenced, runtime sees its not actually a slice and hence treats it as if its a nil slice ? thanks, Santhosh. > > Ian > -- 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.