On Tue, Jun 8, 2021 at 12:08 PM Ian Davis <m...@iandavis.com> wrote:

> When a method with a non-pointer receiver is called, is the copy made 
> atomically? My intuition says it must be but perhaps someone else can confirm 
> it?

I don't think the specs require that and I don't think well known
implementations try to enforce it. Also, above machine words it gets
complicated.

> If so, how does it work?

The receiver of a method is just the first parameter of an otherwise
ordinary function. I believe it's passed as any other argument,
currently by pushing it to the stack by the caller in case of gc, for
example. gccgo may already use registers, but that I'm only guessing.
(C ABI usually uses registers, but Go with gccgo may differ.)

FTR: AFAICT, from the perspective of the method, its receiver is
passed always by value, regardless if the method is declared on a
pointer receiver or not because a pointer is also a quite normal
value.

-- 
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/CAA40n-U3q%2BjJDjrq7DuKKn2mjCWjnH4bNo7CYxQ39nbDtVx%2BGw%40mail.gmail.com.

Reply via email to