They're right, you're confused on multiple issues. Another thing you're confused about is when you say "A pointer is not an address. A pointer has an address, and a pointer points to or contains an address, but a pointer is not itself an address."
That is simply wrong, from start to end. Not only is a pointer exactly the same thing as a machine address, as has already been said, but furthermore, pointers do not in general have addresses.
They are values. What you said is like saying "2 has an address". No, it does not. 2 is a value, and it can be stored in multiple addresses, it doesn't have to be (it might exist only in a machine register with no address), and certainly doesn't have to be contained in a unique address.
Perhaps you skipped the assembly language and machine architecture course. One pretty much cannot get confused about these particular issues if one has that prerequisite.
Not only is a pointer exactly the same thing as a machine address
I'm not sure what your reference is, but it doesn't line up with mine. A pointer is a data type. An address is a value. Pointers hold addresses just like ints hold integers and char arrays hold strings.
Wikipedia says:
In computer science, a pointer is a programming language data type whose value refers directly to (or "points to") another value stored elsewhere in the computer memory using its address.
Pointers are a data type in C. You can declare variables of pointer types. Addresses are a property of RAM. Not the same.
What you said is like saying "2 has an address".
No, because 2 is not a pointer. Pointers are variables. What I said was:
int foo = 4;
int* pFoo = &foo;
pFoo contains an address (the address of foo, where 4 is stored in memory). It also has an address (&pFoo, which is wherever on the stack pFoo was created).
Perhaps you skipped the assembly language and machine architecture course.
I've been doing compiler work longer, in all likelihood, than you've been alive, and you are getting tiresome with this "yes it is, no it isn't, yes it is, no it isn't" crap. Address my point about "&a" being a pointer, if you insist on continuing to be smug.
Edit: P.S. my comment about long time compiler work is not to claim superiority, it's to indicate why it irritates the hell out of me for you to continue to insist that I'm confused over newbie issues, without addressing the substance of my most recent comments (referred to with "see above", and which brought up "&a" as a pointer), and why I don't automatically take wikipedia to be authoritative -- I could write that article from scratch myself, and the phrasings would be more accurate if I did.
So put up or shut up.
P.P.S. it's also to indicate that I actually have expertise concerning the topic's application to many languages, not just C, and to its history, which I've studied -- but since one of my nearby comments that gave a URL for C.A.R. Hoare's thoughts was modded down, I guess this is a tough crowd -- neither interested in my anonymous expertise, nor that of a world famous computer scientist. :-P
I'm not really doubting that you know what a pointer is, which is why I'm sure this is just a pedantic argument. As retarded as Internet Arguments get, the pedantic ones are the worst.
I think you're referring to "pointer" as the memory address itself, and munificent (and I) are using "pointer" to refer to the variable that contains that address. That's it.
Ok, that's all utterly reasonable. Sorry for contributing to hating the internet....I think we all started out meaning well, then got a bit irritated and short with each other. Thanks for closing this way.
In C, "&foo" is a pointer. It also, without any possibility of argument, is a machine address: the location in RAM that the variable "foo" corresponds to."
But although "&foo" is an address, does it have an address? In general, no, unless you save it in a variable. More typically it is a value, and one which most often lives only in a register.
Everyone who modded you up and modded me down apparently misunderstand that central point.
I like wikipedia, and I contribute regularly, but on this topic, the particular phrasings used in wikipedia are seriously misleading.
The side issue of what is a type in C is not something that I intended to address here, but as a compiler professional, I certainly could talk about that side issue if you care.
But as a side note, if you check your textbooks you'll find that there is not an inherent dichotomy between "type" and "value". It depends on the language and usually also on which particular example constructs in a language are under discussion.
For instance, in C, "int a; &a;" the "&a" construct has type "pointer to int", and is a value. You can also of course say "typedef int **bp;", and then "bp" is (not has) type "pointer to int", and "bp" is not a value.
There are nuances to these things. But feel free to mod down people rather than discussing things. :-P
The first of which is the address in memory where the string "foo" resides. The second is the address in memory where the pointer resides.
edit: I understand we're just talking terminology here. The problem is, if you're not going to call it a 'pointer', then what are you gonna call it? In my interpretation, a pointer is the type. The pointer occupies memory (32 bits on a 32-bit architecture, AFAIK0, has an address, and contains an address. The pointer points to the address it contains, which is the address of something else in memory, whatever it is.
It's not just terminology. Similarly to what I said nearby, "&a" is an address, but it doesn't have an address, now does it?
"&a" is a value, and although in some contexts it gets stuck in memory, it most certainly does not always get stuck in memory.
So since "&a" is a pointer, it follows that pointers do not always occupy memory.
You and others are thinking of the instances where there is a variable of type pointer-to-something. But pointers exist even in the absence of such variables, you see.
View all comments
Show parent comment
-6
u/wildeye Jul 23 '08
They're right, you're confused on multiple issues. Another thing you're confused about is when you say "A pointer is not an address. A pointer has an address, and a pointer points to or contains an address, but a pointer is not itself an address."
That is simply wrong, from start to end. Not only is a pointer exactly the same thing as a machine address, as has already been said, but furthermore, pointers do not in general have addresses.
They are values. What you said is like saying "2 has an address". No, it does not. 2 is a value, and it can be stored in multiple addresses, it doesn't have to be (it might exist only in a machine register with no address), and certainly doesn't have to be contained in a unique address.
Perhaps you skipped the assembly language and machine architecture course. One pretty much cannot get confused about these particular issues if one has that prerequisite.