Better HN
topnewbestaskshowjobs
Log inSign up

eraxley

4 karma · joined Feb 6, 2017 (9y ago) · 1 submissions

Submissions

comment 7y ago · link · parent

You are right that (2) needs to be dereferenced first, however, in go a pointer is autmatically dereferenced when accessing its properties or "methods". What I mean by this is that if you want to access a property on thing, it would look the same.

In C++ it would look like this:

  (1) x = thing.Property;
  (2) x = thing->Property; (or (*thing).Property)
but in go, both would look the same, like this:

  (1) x = thing.Property
  (2) x = thing.Property
So there is a difference syntactically, and the compiler will handle them differently, but whether the difference is semantically relevant is debatable.