Andrey Tarasevich <an**************@hotmail.com> writes:
ccwork wrote: ...
How can an array be an lvalue, if you can't assign to it?
...
I don't understand why array is lvalue. To me the answer is saying
that array is NOT lvalue.
...
In C language the term "lvalue" has absolutely nothing to do with being
or not being assignable.
Well, yes and no. Only lvalues are assignable, but not all lvalues
are assignable.
Lvalue is any value of object type (or non-void
incomplete type). The idea of lvalue in C is that any object that has a
location in memory is "lvalue" ("l" stands for "location"). Whether you
can assign to it or not is completely irrelevant.
42 is a value of object type (specifically int), but it's not an
lvalue (the definition in the C99 standard implies that it is, but
that's not the intent). An lvalue is an expression that designates
an object, at least potentially (e.g., given
char *ptr;
the expression *ptr is an lvalue, even if ptr==NULL).
The 'l' in lvalue originally stood for "left", as in the left hand
side of an assignment; an rvalue was an expression that could appear
on the right hand side of an assignment. By the time C was
standardized, the meaning of "lvalue" came to include things that
can't be on the LHS of an assignment, and the term "rvalue" was
dropped. "location value" is a good mnenomic for the current meaning
of the term, but it's a later invention.
--
Keith Thompson (The_Other_Keith)
ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.