The below code doesn't compile. The error message I understand, but I don't see why this shouldn't work. The compiler would have to make an extra step, i.e. after fetching the value from the array and doing the loop calculations writing the result back to the array. The compiler already detects that the variable is modified, so writing it back in the end of the loop should be no problem.
Is there an explanation why this shouldn't work?
The iterations aren't changed by such an action. In opposite in a normal for..to loop this would be the case.
program Project1;
var
scalar: double;
vector: array of double;
begin
for scalar in vector do scalar:= 0; //Error: Illegal assignment to for-loop variable "scalar"
end.