On Thursday, 14 November 2013 at 02:37:52 UTC, logicchains wrote:
On Wednesday, 13 November 2013 at 16:12:01 UTC, Andrei
Alexandrescu wrote:
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
Looking through the Go spec, it seems I was confused. A pointer
to a struct can be used with just pt.X, and a pointer to an
array *arrp can be used with just arrp[0], but a pointer to a
_slice_ *slcp can only be used with (*slcp)[0], not slcp[0]. I
have no idea why this is.
Because slices are always references, so you have a double
indirection.