Re: [go-nuts] Re: The &(*x) idiom for copying.

2018-03-28 Thread thwd
[...] a copy *of* the pointed-to value. On Wednesday, March 28, 2018 at 6:54:53 PM UTC+2, thwd wrote: > > Hi. Don't worry, I do get pointers and pass-by-value. > > I expected the expression (*x) to yield a copy to the pointed-to value. > > But, as you say, that happens on assignment. > > On

Re: [go-nuts] Re: The &(*x) idiom for copying.

2018-03-28 Thread thwd
Hi. Don't worry, I do get pointers and pass-by-value. I expected the expression (*x) to yield a copy to the pointed-to value. But, as you say, that happens on assignment. On Wednesday, March 28, 2018 at 6:50:06 PM UTC+2, Devon H. O'Dell wrote: > > 2018-03-28 9:39 GMT-07:00 Devon H. O'Dell

Re: [go-nuts] Re: The &(*x) idiom for copying.

2018-03-28 Thread Devon H. O'Dell
2018-03-28 9:39 GMT-07:00 Devon H. O'Dell : > CopyExplicitDeref gets a pointer to the struct in its receiver. If you > have a pointer to T, then taking a pointer to the dereferenced T is a > no-op: you get the pointer of the thing you just dereferenced. Any > statement

Re: [go-nuts] Re: The &(*x) idiom for copying.

2018-03-28 Thread Devon H. O'Dell
CopyExplicitDeref gets a pointer to the struct in its receiver. If you have a pointer to T, then taking a pointer to the dereferenced T is a no-op: you get the pointer of the thing you just dereferenced. Any statement &*whatever will always yield the value of whatever. Copy happens on assignment,