3 ms·
It's a good article, however I've always thought lvalue meant "left-value" (i.e. a value that can appear as the left part of an assignment) but this article say
by simias 15y ago
It's a good article, however I've always thought lvalue meant "left-value" (i.e. a value that can appear as the left part of an assignment) but this article says it stands for "locator value". Who's right? And then what does rvalue stand for if not "right-value"? Register value? I find no definite answer on Google.
- mrcharles 15y agoThis was my understanding as well. My mind abstracted "right-value" to "anything that can be assigned." If you look at the relations of lvalue and rvalue to the assignment operator (=), you can see that it's a consistent definition too. It also follows the same rules in that 'rvalues are defined by exclusion.'
- jonsen 15y agoThe word lvalue was originally coined to mean "something that can be on the left side of an assignment." Bjarne Stroustrup, The C++ Programming Language, 2nd ed., p 47.
- 16s 15y agoThat's how I've always thought of it as well.
- divtxt 15y agoEveryone here agrees that it's left/right. (even if that's not correct) Left/right is so much easier to both remember and understand the terms.
- Sharlin 15y agoAs the article points out, the original meaning of the "l" in "lvalue" indeed was "left". However, in C and C++ there are lvalues that cannot appear as the left-hand-side of assignment (const variables, arrays, functions) and rvalues that can (in C++ you can say, for example, C() = C(); for some class C because the assignment operator is just a member function, and member functions can be called for rvalues.) What more accurately grasps the definition of lvalues and rvalues in C and C++ standards is that the former have an individual identity (concretely, they are permitted as the operand of the address-of operator &) and the latter don't. (Except don't get me started on the fact that in C++ one can overload operator&...)
- eliben 15y agoHere's a telling footnote from the C99 standard: "The name ‘‘lvalue’’ comes originally from the assignment expression E1 = E2, in which the left operand E1 is required to be a (modifiable) lvalue. It is perhaps better considered as representing an object ‘‘locator value’’. What is sometimes called ‘‘rvalue’’ is in this International Standard described as the ‘‘value of an expression’’."