r/C_Programming • • Apr 24 '24

The way C Programers explain pointers

https://imgs.xkcd.com/comics/pointers.png
652 Upvotes

50 comments sorted by

View all comments

Show parent comments

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.

0

u/EpochVanquisher Apr 24 '24

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

13

u/Marxomania32 Apr 24 '24

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.

0

u/EpochVanquisher Apr 24 '24

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