Hacker News new | ask | show | jobs
by sftrabbit 4286 days ago
You can have values that don't belong to objects. I consider there to be three types of value computations:

- The value computations of operators, like 5 + 6. These don't use the values of objects. They just use the values of their operands. The operands may be subexpressions that denote objects (like 5 + x), but it is the value computation of those subexpressions that uses the object's value, not the value computation of the operator.

- The value computations of expressions denoting objects where the expression is being used as an lvalue. These also don't use the values of objects - they only care about the object's storage location. I give an example in the article, which is the left operand of =.

- The value computation of expressions denoting objects where the expression is being used as an rvalue. This means lvalue-to-rvalue conversion is performed, which is conceptually "reading an object's value out of memory". This, therefore, uses the value of the object.

1 comments

Just to make sure I've got the terminology down.

Objects correspond to locations in memory.

5 + 6 has operands which are rvalues (and thus not objects because you can't take their address).

if x is an int, then in the context of the expr 5+x, it is undergoing lvalue-to-rvalue conversion

Did I get that right?