This helps a lot, thanks.lexikos wrote: ↑10 Sep 2023, 06:44
In the current implementation (and this should not be taken as any kind of guarantee), a variable is not dereferenced before becoming input to an operator or function. The variable itself is the input, and the operator or function dereferences the variable if that is what it is designed to do. An operator will use whatever value the variable has when the operator is evaluated, not the value one operand had before the other operand was evaluated. This is consistent across all operators, so for instance, &++x takes a variable reference, (++x) /= 2 increments and then halves, and ++x + ++x does what it does.
It occurs to me that if, for whatever reason, you really want the values (rather than variable reference) be used, it's possible to use throwaway variable assignments:
For example, compare this
Code: Select all
i := 1
j := ++i + ++i ; 6
Code: Select all
i := 1
j := (_x := ++i) + (_y := ++i) ; 5
Code: Select all
i := 1
arr2 := [++i, ++i, ++i] ; [4,4,4]
Code: Select all
i := 1
arr2 := [_x := ++i, _y := ++i, _z := ++i] ; [2,3,4]