Ask HN: Why Golang uses dot for pointers

1 points by fithisux ↗ HN
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.

5 comments

[ 4.6 ms ] story [ 26.2 ms ] thread
> more sensible to borrow the C notation

IMHO, 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?

So, why keep curly braces in Go? A thing of the past (counter example).
Curly braces are way less intrusive than relying on indentation or riddling the code with do .. end, in my opinion.

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.

> Wouldn't it be more sensible to borrow the C notation -> ?

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`.

Thank you, I need to invest more time. Still, not persuaded (the dot does a lot) but the source you mentioned seems reasonable. Maybe I need to be more open minded.