HACKER Q&A
📣 fithisux

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.


  👤 stefanos82 Accepted Answer ✓
> 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`.


👤 JTyQZSnP3cQGa8B
> 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?