On Mon, Aug 22, 2016 at 10:37 PM, T L <
tapi...@gmail.com> wrote:
>
> On Tuesday, August 23, 2016 at 1:28:03 PM UTC+8, T L wrote:
>>
>> Looks this question can be stated as "why can't named pointer types have
>> methods?"
>
>
> Just found this thread
>
https://groups.google.com/forum/#!topic/golang-nuts/Vhh5XOm96YI
> to answer "why can't named pointer types have methods?"
>
> But I think the two questions are not totally equivalent:
> 1. Why a **T value can't call methods of *T?
> 2. Why can't named pointer types have methods?
Your second question has been answered.
The first question is, essentially, what is the method set of **T?
The answer is: **T has no methods. Why should it?
T has methods (or at least may have methods): the methods whose
receiver is type T. *T has methods: the methods whose receiver is
type *T. For convenience, the methods of T are added to the method
set of *T.
**T does not have methods. There is no reason to add the methods of
*T to the method set of **T, because the method set of **T is empty.
Ian