C++ sequenced-before graphs
josephmansfield.uk
josephmansfield.uk
I don't quite understand the difference. Don't all value computations use the values of objects?
- 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.
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?
Don't write multiple assignments in a single statement. Don't overuse the ternary operator (?:). Don't overdo it with assignment inside larger statements like comparisons. These "don'ts" will make your code clearer to humans and you are much, much less likely to wind up with holes in your feet.
Anyway, the problem with using assembly is that it imposes an artificial temporal total ordering on the actions being performed. Under temporal total ordering, the possibility of unsequenced actions disappears, and the message is lost.
>no-one outside of compiler developers has the right vocabulary for descriptions to work
There's nothing here specific to implementing compilers. There are a few uses of standardese and graph theory, but they're relatively basic concepts that are important to familiarize yourself with if you want to use tools like C++ effectively.