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 number 10
. 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 :
int x;
x = 5 * 2;
Here x
refers to a certain memory address and the calculated number (10) can now be stored where x
refers to (i.e. in the memory space assigned to x
) via the assignment operator. So in the example above x is the LValue and the expression 5 * 2
is the RValue