In computer science, a value is an expression which cannot be evaluated any further (a normal form). The members of a type are the values of that type. For example, the expression 1 + 2
is not a value as it can be reduced to the expression 3
. This expression cannot be reduced any further (and is a member of the type Nat) and therefore is a value.
The "value of a variable" is given by the corresponding mapping in the environment. In languages with assignable variables it becomes necessary to distinguish between the r-value (or contents) and the l-value (or location) of a variable.
In declarative (high-level) languages, values have to be referentially transparent. This means that the resulting value is independent of the location in which a (sub-)expression needed to compute the value is stored. Only the contents of the location (the bits, whether they are 1 or 0) and their interpretation are significant.
Some languages use the idea of l-values and r-values, deriving from the typical mode of evaluation on the left and right hand side of an assignment statement. An lvalue refers to an object that persists beyond a single expression. An rvalue is a temporary value that does not persist beyond the expression that uses it.
The notion of l-values and r-values was introduced by CPL. The notions in an expression of r-value, l-value, and r-value/l-value are analogous to the parameter modes of input parameter (has a value), output parameter (can be assigned), and input/output parameter (has a value and can be assigned), though the technical details differ between contexts and languages.