The fact that https://github.com/golang/go/issues/5083 still hasn't
been sorted out means that it's hard to explain this to people using
officially sanctioned terminology. I usually end up just using the
phrase "reference types" along with some further description of what I
mean (in particular to distinguish from something like C++
references). It would be quite helpful if we could nail this down at
some point. Having a good spec-level description means that we
shouldn't have to talk about machine words or method tables to explain
what values are.

We could even make up a new term if we don't like the baggage of
"reference". (As I joked in a previous thread, "goference".)

On Tue, Apr 18, 2017 at 2:21 PM, Ian Lance Taylor <i...@golang.org> wrote:
> On Tue, Apr 18, 2017 at 2:13 PM, st ov <so.qu...@gmail.com> wrote:
>> I read everything is pass-by-value in Go, is that correct?
>> What does it encompass? Are there any exceptions?
>
> There are no exceptions.  But it does require a clear understanding of
> what Go means by a value.
>
>> Does that mean the following:
>>
>> int passes full integer byte value
>> float64 passes full float byte value
>> string passes full string []byte value
>
> Not really, a string passes a pointer (to an immutable []byte) and a length.
>
>> slice passes pointer value to slice in memory
>
> Not really, a slice passes a pointer to a backing array, a length, and
> a capacity.
>
>> map passes pointer value to map in memory
>> func passes pointer value to func in memory
>> interface passes pointer value to interface object in memory
>
> Almost, an interface passes a pointer to a method table and a pointer value.
>
> See https://research.swtch.com/godata .
>
> 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.

-- 
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.

Reply via email to