I just read the C reference about prefix increment operator and realized that the result of prefix increment operator are not lvalue, but it's surprising that it is lvalue in C++. After that I read this answer which explaining why it's a lvalue, but I don't understand it:
(Line 3): ["] it appears that it is so you can take its address or assign to a reference. [."]
and an example follows:
int i; extern void f (int* p); f (&++i); /* Would be illegal C, but C programmers havent missed this feature */ ...
So what's the merit of allowing this? Is the only purpose of this that incrementing i
in global region is illegal? If this is the only reason I would consider this be a remedy for a defect in C that cannot/hard to be resolved, or the program should probably be rewritten for the sake of readability, right?
btw I don't understand why lvalue is also called "locator value", I've read this - line 4 but locator is vague for me. What's a locator, is it a pointer something?
EDIT: For the sake of your precious time reading about wth is locator value, here is my homemade backronym:
- lvalue: location value, you know the location of it.
- rvalue: read value, you can only read the value.
don't blame me if anything gone wrong.