I'm reading a tutorial and it seems like the author is saying that unless a variable goes through an addressing scheme it is actually a constant as far as the compiler is concerned. Is that what they are implying?
"Now, let's delve a little further into the difference between the names ptr and my_array
as used above. Some writers will refer to an array's name as a constant pointer. What do
we mean by that? Well, to understand the term "constant" in this sense, let's go back to
our definition of the term "variable". When we declare a variable we set aside a spot in
memory to hold the value of the appropriate type. Once that is done the name of the
variable can be interpreted in one of two ways. When used on the left side of the
assignment operator, the compiler interprets it as the memory location to which to move
that value resulting from evaluation of the right side of the assignment operator. But,
when used on the right side of the assignment operator, the name of a variable is
interpreted to mean the contents stored at that memory address set aside to hold the value
of that variable.
With that in mind, let's now consider the simplest of constants, as in:
int i, k;
i = 2;
Here, while i is a variable and then occupies space in the data portion of memory, 2 is a
constant and, as such, instead of setting aside memory in the data segment, it is imbedded
directly in the code segment of memory. That is, while writing something like k = i; tells
the compiler to create code which at run time will look at memory location &i to
determine the value to be moved to k, code created by i = 2; simply puts the 2 in the code
and there is no referencing of the data segment. That is, both k and i are objects, but 2 is
not an object.
Similarly, in the above, since my_array is a constant, once the compiler establishes
where the array itself is to be stored, it "knows" the address of my_array and on
ptr = my_array;
it simply uses this address as a constant in the code segment and there is no referencing
of the data segment beyond that." It's from page twelve and here is the link if more context is needed..
Thanks is advancehttp://docs.google.com/viewer?a=v&q=...AEIKFzsO2HojPQ