Re: [go-nuts] why received can be defined with/without pointer?

2017-05-09 Thread Volker Dobler
I must admit you lost me. Thus just some minor notes: On Tuesday, 9 May 2017 16:05:16 UTC+2, mhh...@gmail.com wrote: > > > Help me to not copy a pointer value when its inappropriate. > Copying a pointer value is one of the most trivial and fast operations imaginable. Maybe you are using the

Re: [go-nuts] why received can be defined with/without pointer?

2017-05-09 Thread mhhcbon
On Tuesday, May 9, 2017 at 2:21:52 PM UTC+2, Volker Dobler wrote: > > On Tuesday, 9 May 2017 12:30:38 UTC+2, mhh...@gmail.com wrote: >> >> in short and put straightly, >> 1- i think its not appropriate to let us >> define pointer/non pointer attribute >> of a type over multiple points in the

Re: [go-nuts] why received can be defined with/without pointer?

2017-05-09 Thread Jan Mercl
On Tue, May 9, 2017 at 2:22 PM Volker Dobler wrote: > Go offers two types of methods, those > defined on value types and those defined on pointer types. To avoid possible confusion: It's not possible to attach methods to a pointer type. The receiver has form T or *T,

Re: [go-nuts] why received can be defined with/without pointer?

2017-05-09 Thread Volker Dobler
On Tuesday, 9 May 2017 12:30:38 UTC+2, mhh...@gmail.com wrote: > > in short and put straightly, > 1- i think its not appropriate to let us > define pointer/non pointer attribute > of a type over multiple points in the code. > In my experience of a beginner, its a pain that teaches you to always

Re: [go-nuts] why received can be defined with/without pointer?

2017-05-09 Thread mhhcbon
thanks, > The definition of the method always makes it clear whether you are passing a value of the type or a pointer to the type. People defining methods on large types should know which one want to use. in short and put straightly, 1- i think its not appropriate to let us define

Re: [go-nuts] why received can be defined with/without pointer?

2017-05-08 Thread Ian Lance Taylor
On Sun, May 7, 2017 at 3:37 AM, wrote: > yes, sorry you scratched your head > > https://play.golang.org/p/Gg6Euyvsw6 > > this example shows that it is possible to do all the things. > hth. > > I m curious to know more about other questions. > Maybe they are not good idea, or

Re: [go-nuts] why received can be defined with/without pointer?

2017-05-07 Thread Rader Lei
if a method only defined for a pointer receiver, the compiler will add "*" before the caller silently. Why pointer receiver? Try to change the value of a member. You will know the difference. On Sunday, May 7, 2017 at 6:37:59 PM UTC+8, mhh...@gmail.com wrote: > > yes, sorry you scratched your

Re: [go-nuts] why received can be defined with/without pointer?

2017-05-07 Thread mhhcbon
yes, sorry you scratched your head https://play.golang.org/p/Gg6Euyvsw6 this example shows that it is possible to do all the things. hth. I m curious to know more about other questions. Maybe they are not good idea, or not technically achievable. Just curious. On Sunday, May 7, 2017 at

Re: [go-nuts] why received can be defined with/without pointer?

2017-05-06 Thread Ian Lance Taylor
On Sat, May 6, 2017 at 3:39 AM, wrote: > > Question about the receiver of a func. > > It can be defined as star/no star, and consumed as star/nostar. > > The understanding i have so far is, > it let the developer define the memory model he d like to use. > > It leads to cases

[go-nuts] why received can be defined with/without pointer?

2017-05-06 Thread mhhcbon
Hi, Question about the receiver of a func. It can be defined as star/no star, and consumed as star/nostar. The understanding i have so far is, it let the developer define the memory model he d like to use. It leads to cases such as - define start/nostar on a type - consume a stared type as a