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
View all comments
Show parent comment
6
u/munificent Jul 23 '08
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:
Pointers are a data type in C. You can declare variables of pointer types. Addresses are a property of RAM. Not the same.
No, because 2 is not a pointer. Pointers are variables. What I said was:
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).
No, I did not.