consider the following example:
[MATH]j:2[/MATH]
[MATH lang=ENG]for(j,range(1,4),a:j)[/MATH]
[MATH]j=4[/MATH]
Now edit the loop expression and change it to any expression without assignment operator with or without j in it
[MATH lang=ENG]for(j,range(1,4),a)[/MATH]
When leaving the math region, nothing happens.
[MATH]j=4[/MATH]
As soon as you trigger re-calculation manually, j changes to 2, indicating that the loop iteration is not performed in the global namespace.
[MATH]j=2[/MATH]
Still there is iteration as you can see using [MATH]trace(j)[/MATH] as loop body.
[MATH lang=ENG]for(j,range(1,4),trace(j))[/MATH]
I think, that changes in expressions should trigger re-calculation if that option is set in the options.
Also, I really discourage the use of implicit variable scoping magics. I guess that it is not by intent to overwrite the global imaginary unit i depending on what precisely you do inside iterations with i as counter.
If the mentioned dependency is a feature and not a bug I would like to learn how this contributes to comprehensable documents.
Best regards, Martin Kraska
Martin Kraska
Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx