There are two kinds of expressions in Objective-C
1. RValue
The term rvalue refers to a data value that is stored at some address in memory
2. LValue
Expressions that refer to a memory location is called "lvalue" expression. An lvalue may appear as
either the left-hand or right-hand side of an assignment
I didn't get it . can someone explain it to me?
RValue is a value that is evaluated but does not have a designated memory address to be stored until assigned to such a memory location. For example :
5 * 2
is an expression evaluated to the number10
. This evaluated expression is still not assigned to a memory address (only a temporary one used for the calculation but you cannot directly refer to it) and will be lost if not stored. And this is the role of the LValue to provide a memory location to store the evaluated expression :Here
x
refers to a certain memory address and the calculated number (10) can now be stored wherex
refers to (i.e. in the memory space assigned tox
) via the assignment operator. So in the example above x is the LValue and the expression5 * 2
is the RValueRoughly speaking,
lvalue
are values that can be assigned to. In C and Objective-C, those are usually variables and pointer dereferences.rvalue
s are results of expressions that can't be assigned to.Some examples:
See the Wikipedia article and this article here for more details.