Being able to do arithmetic on pointers and be able to arbitrarily dereference them is what makes them pointers. Other languages have references, which almost certainly end up being implemented with a pointer somewhere underneath the hood, but that doesn't make them pointers.
Incorrect. People still call them “pointers” even if you can’t dereference them at all (like void*). People also still call them pointers even if you can’t do arithmetic on them (like function pointers).
That's a good point, but I still disagree since, in the end, those pointer types can always be cast to at least one different pointer type (char *) that you can do pointer arithmetic and do arbitrary dereferences on. Reference semantics ultimately do have entirely different semantics from pointers, so they are different.
“Reference semantics” and “pointer semantics” are kind of vague terms. The terms are used differently in different languages. C has pointers in the language standard but “references” is not a technical term in C. C++ has a technical notion of references but it is different from the semantics for references in other languages.
17
u/Marxomania32 Apr 24 '24
Being able to do arithmetic on pointers and be able to arbitrarily dereference them is what makes them pointers. Other languages have references, which almost certainly end up being implemented with a pointer somewhere underneath the hood, but that doesn't make them pointers.