Many of the times my compiler shows errors like Lvalue or Rvalue Required.
What are the Lvalues and Rvalues in C or any programming languages?
Is a pointer constant a rvalue?
|
Many of the times my compiler shows errors like Lvalue or Rvalue Required. What are the Lvalues and Rvalues in C or any programming languages? Is a pointer constant a rvalue? |
||||
|
The terms are somewhat language-specific; they were first introduced in CPL. Being an lvalue or an rvalue is a property of an expression; that is, every expression is either an lvalue or an rvalue. You will often find explanations that deal with the left and right side of an assignment. That is the historical origin of the letters l and r in lvalue and rvalue, but it does not hold anymore. For example, there are lvalues that can not stand on the left side of an assignment (expressions denoting arrays and constant variables come to mind, but also class types where the assignment operator has been hidden or deleted), and at least in C++, there are rvalues that can stand on the left side of an assignment. The best definition that I know of is: an lvalue is an expression to which the unary Since C++11, the language also has the notions of xvalues, prvales und glvalues (see here and here).
Expressions that denote pointer variables like Java doesn't have the notion of lvalues, but in §15.1 the Language Specification states:
|
||||
|
|
a, b = getTuple(). – Christian Jul 5 '12 at 9:36