3 ms·
C and Asm at least... and "address of the pointer" is something entirely different. For example (assuming a 16-bit system and radix 16 for brevity), Name:
by userbinator 6y ago
C and Asm at least... and "address of the pointer" is something entirely different. For example (assuming a 16-bit system and radix 16 for brevity),
Name: Address: Value:
p 0100 02 01
v 0102 12 59
p is the pointer. The address of p is 0100. The contents of p are the two bytes which form the address of v, 0102. The contents of v are the two bytes which form the value 5912.
I wonder if this confusion of the pointee with the pointer is what makes this concept seem so difficult to those who didn't start with Asm (especially multiple indirections) --- I certainly saw a lot of that when I used to teach CS courses.
- bregma 6y ago> I wonder if this confusion of the pointee with the pointer is what makes this concept seem so difficult to those who didn't start with Asm Possibly (I started with asm, so I can't speak with certainty) but it could also be because many modern programmers first learned Java or JavaScript or Python in which most names are references to object (thus effectively all variables are addresses). Their first languages do not have value semantics, so grasping the concept of value semantics applied to a reference itself (ie pointers) is a major stretch.
- nicoburns 6y agoJavaScript does have value semantics for booleans and numbers. But it doesn't have any reference types which allow you to inspect the reference as a value.
- ptx 6y agoIn Python, everything is a pointer to a PyObject and always passed by value, so thinking of them as values makes sense. You can even easily get the address of the pointer by calling id on it (but not as easily convert it back).
- gpderetta 6y agodoesn't id return the address of the pointee?
- ptx 6y agoAh, yes - the value of the pointer, which is an address, the address of the pointee. (Even after reading that other thread, I messed up my terminology.) Actually, id returns a pointer to a PyObject representing an integer, the value of which is the value of the pointer that was passed as an argument, which is the address of the pointee. Right?