So, I know that many C-style languages have decrement (--
) and increment (++
) operators, and allow the mutation to happen before or after the whole expression is evaluated.
What happens when a post-increment happens on a return? I'm not asking in terms of behaviour, but rather implementation.
Given a virtual machine (e.g. JavaScript/JVM) or physical machine (e.g. compiled C++), are the generated opcodes something like the following? (Assuming stack-based arguments/returns.)
int x = 4, y = 8;
return f(++a) + y++;
Turns into this: (Maybe?)
LOAD 4 A
LOAD 8 B
INC A
PUSH A
CALL F
POP INTO C
ADD C BY B
INC B
RET C
If so, how do such operations in these languages decide where to embed the incrementation when the expression becomes complex, perhaps even a little Lispish?