Order of evaluation
Apart from assignment, all expressions are always evaluated from left to right. Be it math/bitwise/comparison or parameters to functions or elements of an immediate list.
“a+b*c” is evaluated as:
- load value of a
- add value of b
- multiply with value of c
“bla(x[]++, x[]++)” is evaluated as:
- load value of x[] as first parameter
- increment x
- load value of x[] as second paramater
- increment x
- call function
Assignment always evaluates right hand side expression first, then if needed, evaluates the left hand side.
“x[exp] := y[]++” is evaluated as:
- load value from y[]
- increment y
- evaluate exp
- store value in x[exp]