On Sun, Jul 9, 2017 at 12:30 AM, Dave Cheney wrote:
> As your using the unsafe package your doing things which are not
> considered safe by the lanaguge so only imprecise interpretations are
> possible. My interpretation is, assuming that next words after p in memory
> are zeroed the you have eff
On Sunday, July 9, 2017 at 6:31:24 AM UTC+8, Santhosh Ram Manohar wrote:
>
> hello,
>
> This piece of code prints [10 0 0 0] as expected..
>
> func main() {
> i := 10
> p := unsafe.Pointer(&i)
> intPtr := (*[4]byte)(p)
> fmt.Println(*intPtr)
> }
>
> But if I conver
As your using the unsafe package your doing things which are not considered
safe by the lanaguge so only imprecise interpretations are possible. My
interpretation is, assuming that next words after p in memory are zeroed the
you have effectively a slice that points to a backing array at *p, and
On Sat, Jul 8, 2017 at 7:37 PM, Ian Lance Taylor wrote:
> On Sat, Jul 8, 2017 at 6:59 PM, Santhosh Ram Manohar
> 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 a
On Sat, Jul 8, 2017 at 6:59 PM, Santhosh Ram Manohar
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 d
Dave,
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 int