3 ms·
> References are opaque handles for values, you can just deference them and compare them for equality. Pointers are not opaque, their values are address and you
by nordsieck 9y ago
> References are opaque handles for values, you can just deference them and compare them for equality. Pointers are not opaque, their values are address and you can perform arithmetic on them.
What about Go?
It claims to have pointers. You can't do arithmetic on them, but you can take the address of a pointer so you can do all the cute double dereference list and tree algorithms.
- danbruc 9y agoI never used Go in any meaningful way so I just had to look at the documentation. I lean towards classifying it as references instead of pointers despite the name. References to references are perfectly valid even though they are not available in all languages with references. On the other hand Go exposes an implementation detail, the fact that references are implemented as addresses. This is probably true for most languages with references but they usually keep this an implementation detail so that it would be perfectly valid to implement references with something other then addresses. But because you can not really take advantage of the fact that references are implemented using addresses, you can not manipulate them and it seems you can not even calculate the difference between two pointers unless you go through unsafe, I would call it references [with slightly but inconsequentially exposed implementation]. As said, this is based on a ten minute read through the first couple of search results and I probably have not even hit any official documentation, so this might very well miss something important and be wrong.