6 ms·
I personally (emphasis intentional) consider the core distinction between "references" and "pointers" to be whether you can do pointer arithmetic on the pointer
by jerf 10y ago
I personally (emphasis intentional) consider the core distinction between "references" and "pointers" to be whether you can do pointer arithmetic on the pointers. Pointers without pointer arithmetic aren't hardly scary at all, especially in languages where there is no way to deallocate the underlying value but leave the pointer behind such that it may point to the wrong thing later, be that due to something like Rust or with GC like Go.
So personally, I think of Go as having references, but not pointers (outside of unsafe).
Of course every language community uses those terms its own way, but that seems to me to be the most broadly useful way of looking at it.
- steveklabnik 10y agoI've spent a lot of time on this, working on Rust's docs, and the way I see it is that "pointer" is the most generic concept, with "reference" being a more restricted form. So all references are pointers but not all pointers are references. Words are hard.