Ask HN: Why Golang uses dot for pointers
Wouldn't it be more sensible to borrow the C notation -> ?
It would be easy to understand that the LHS is a pointer. Now, it needs some mental work to disambiguate.
It would be easy to understand that the LHS is a pointer. Now, it needs some mental work to disambiguate.
5 comments
[ 4.6 ms ] story [ 26.2 ms ] threadIMHO, it would not because Go has been created for devs who have little programming experience, i.e. not necessarily C or C++. Why bother with symbols of the past?
But Go does have plenty of seemingly unnecessary syntax, especially in its type system. I would prefer it if Go read more like Ruby, Lua or Elixir.
No, because even in C, the operator `->`, like for instance, `pt->foo` it's just a shortcut for `(*pt).foo`; therefore in Go the aforementioned example `(*pt).foo` it's equivalent to `pt.foo`.
For more info, read https://tip.golang.org/ref/spec#Method_values where it talks about `selectors`.