Well, from that standpoint, any structure that has a pointer is a reference
type.

On Fri, Oct 21, 2016 at 8:50 AM, T L <tapir....@gmail.com> wrote:

>
>
> On Friday, October 21, 2016 at 11:37:21 PM UTC+8, Paul Borman wrote:
>>
>> I think you should clarify that this is because T *only* contains
>> pointers.  If T were:
>>
>> type T struct {
>>     i int
>>     p *int
>> }
>>
>>
> Ian says slice is also a reference type. This type declaration is much
> like slice type:
>
> type Slice struct {
> array *internalArray
> len int
> cap int
> }
>
>
>>
>> then it would suddenly become  non-reference type, as defined in this
>> thread, as a change to i will not be noticed by other copies of a given T.
>>
>>     -Paul
>>
>> On Fri, Oct 21, 2016 at 8:20 AM, 'Alan Donovan' via golang-nuts <
>> golan...@googlegroups.com> wrote:
>>
>>> On 21 October 2016 at 11:15, T L <tapi...@gmail.com> wrote:
>>>>
>>>> On Friday, October 21, 2016 at 10:01:43 PM UTC+8, Ian Lance Taylor
>>>> wrote:
>>>>>
>>>>> On Fri, Oct 21, 2016 at 6:52 AM, Henrik Johansson <dahan...@gmail.com>
>>>>> wrote:
>>>>> > The confusion I have had is rather with nilability.
>>>>> > A channel can be nil even though it is not explicitly a pointer.
>>>>>
>>>>> It's a basic design decision in Go that every type has a zero value.
>>>>> For the "reference types" (pointer, channel, map, slice, interface)
>>>>> that zero value is named "nil".
>>>>>
>>>>
>>>> I have a question, should the following type be called reference type?
>>>>
>>>> type T struct {
>>>> p *int
>>>> }
>>>>
>>>
>>> By the definition I gave, yes, because an instance of T contains a
>>> reference to an int variable.  All copies of a given T value share the same
>>> int variable, and a change to that variable by any one will be observed by
>>> all the others.
>>>
>>> --
>>> 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...@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.
>

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