Oh, I only just realized that "pointer indirection" is literally in that
list of addressable things. For some reason I have overlooked that, even
after re-reading the section of the spec several times. That really makes
this clear.

On Wed, 17 Jul 2024 at 06:51, Ian Lance Taylor <i...@golang.org> wrote:

> On Tue, Jul 16, 2024 at 9:29 PM 王旭东 <wxd...@gmail.com> wrote:
> >
> > Hi, I have a question about "addressable."
> >
> > The following code illustrates my question (see the comments):
> > https://go.dev/play/p/xpiPXuEqh0O?v=gotip
> >
> >
> >
> > I also posted question in the Gopher Slack channel, and @Axel Wagner
> provided a detailed explanation, suggesting that this might be a gap in the
> Go specification.
> > @Jason Phillips recommended that I ask this question in the GitHub
> issues and the golang-nuts mailing list.
> >
> > I really appreciate everyone’s help mentioned, but I still don’t have a
> clear conclusion.
> >
> > To simplify: my question is why the result of myfunReturnPointer() is
> addressable if we strictly follow the specification.
>
>
> In https://go.dev/ref/spec#Selectors the spec explains that if the
> type of x is a pointer, then the selector expression x.f is shorthand
> for (*x).f.  That is the case in your playground example: the
> expression myfunReturnPointer().i is short for
> (*myfunReturnPointer()).i.  The pointer indirection
> *myfunReturnPointer() is addressable according to
> https://go.dev/ref/spec#Address_operators.  So this is a field
> selector of an addressable struct operand.
>
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/CAOyqgcUL0D9a0nmXP%2BNJTPrax-ixWFUvRwuUAK5m1G-LtjzH7w%40mail.gmail.com
> .
>

-- 
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/CAEkBMfFB8YNo2V%2BkDXwbDGMCzPyp8tEXHmTt0OBE%3DiSY1%2Bjf6g%40mail.gmail.com.

Reply via email to