Re: [go-nuts] Pointer declaration syntax

2019-03-13 Thread Louki Sumirniy
I may be misunderstanding, but var name = &someOtherVariable is fine but the point is & is a unary operator that means 'return the pointer to the variable to the right of this operator' and is not a type specification, whereas *typename is a type specification that tells the compiler and hin

Re: [go-nuts] Pointer declaration syntax

2019-03-12 Thread Bakul Shah
On Tue, 12 Mar 2019 21:16:21 -0700 Lucio wrote: > > On Monday, 11 March 2019 04:55:26 UTC+2, Rob 'Commander' Pike wrote: > > > > > > Whether a pointer should be declared with & or * or "ptr" or anything else > > is an arbitrary decision made the way it was by the Go designers because, > > as Ian

Re: [go-nuts] Pointer declaration syntax

2019-03-12 Thread Lucio
On Monday, 11 March 2019 04:55:26 UTC+2, Rob 'Commander' Pike wrote: > > > Whether a pointer should be declared with & or * or "ptr" or anything else > is an arbitrary decision made the way it was by the Go designers because, > as Ian says, C did it with *. > >> Not unlike "creat" or "umount", "*

Re: [go-nuts] Pointer declaration syntax

2019-03-10 Thread Rob Pike
& turns a value into a pointer. * turns a pointer into a value. Whether a pointer should be declared with & or * or "ptr" or anything else is an arbitrary decision made the way it was by the Go designers because, as Ian says, C did it with *. -rob On Mon, Mar 11, 2019 at 10:22 AM Michael Jones

Re: [go-nuts] Pointer declaration syntax

2019-03-10 Thread Michael Jones
If you consider lv and rv in BCPL, and see how that becomes * and & in B and stays that way in C/C++/... it may be more clear. The C declaration syntax was revolutionary for being inside out. “int *p” really means “p is the type of variable where *p means an int.” Your argument seems right, in the

Re: [go-nuts] Pointer declaration syntax

2019-03-10 Thread 박민우
Thank you for the explanation! and sorry for the typo, I meant to say something like, someInteger := 0 q := &someInteger or q := &SomeStructure{} as an example of & symbol as "pointer to". Anyway, I would say C's declaration syntax int *p makes more sense because *p , "where p points to", is int

Re: [go-nuts] Pointer declaration syntax

2019-03-10 Thread Yamil Bracho
& just returns an memory address and a variable is just that, a memory address. That the reason you can not apply & to a type... El dom., 10 mar. 2019 a las 10:41, 박민우 () escribió: > I am new to Go and I have read Go;s-declaration-syntax > document

Re: [go-nuts] Pointer declaration syntax

2019-03-10 Thread Ian Lance Taylor
On Sun, Mar 10, 2019 at 7:41 AM 박민우 wrote: > > I am new to Go and I have read Go;s-declaration-syntax documentation. > > It states that: > > p: pointer to int > > Would be written as: > p *int > > However, other than declaration syntax, "&" is the symbol for "the pointer > to" like, > q := &int >

[go-nuts] Pointer declaration syntax

2019-03-10 Thread 박민우
I am new to Go and I have read Go;s-declaration-syntax documentation. It states that: p: pointer to int Would be written as: p *int However, other than declaration syntax, "&" is the symbol for "the pointer to" like, q := &int The above code w