On 11/13/13 4:05 AM, logicchains wrote:
On Wednesday, 13 November 2013 at 11:30:14 UTC, eles wrote:
On Wednesday, 13 November 2013 at 10:19:34 UTC, logicchains wrote:
On Wednesday, 13 November 2013 at 09:12:40 UTC, Jonathan M Davis wrote:

struct, then I have to write (*pt).X to access field X of that

It is in our guidelines too. I almost never write "->".

Ah, right. I just tested, and turns out Go does actually automatically
dereference pointers to structs, but not to arrays. So if arrp is a
pointer to an array, writing arrp[0] is a syntax error in Go, and it
must be written as (*arrp)[0]. D on the other hand, as far as I'm aware
(correct me if I'm wrong), would automatically dereference the pointer.

If the purpose was to make it clear dereference is happening (presumably to have people understand the efficiency issues associated), I wonder why they didn't make memory allocation or indirect calls (both of which abound in Go) more visible. Was there some other intent behind (*pt).X?

Andrei

Reply via email to