I wish to do simultaneous variable assignment in Pascal.
As far as I know, it's not possible. Googling on the issue, I can see that many programming languages implement that, but I can't find how to do it in Pascal.
For example, in Python I can do this:
(x, y) = (y, x)
In Pascal, I need an additional variable to hold the value of x before it's removed, something like this:
bubble := x;
x := y;
y := bubble;
So, is there simultaneous assignment in Pascal, or should I rewrite the code to something like the bubble thing above?
I don't just have to do swaps; sometimes I have to do things like this:
(x,y) = (x+1,y+x)
Would it be ok to do it like the following?
old_x := x;
old_y := y;
x := x + 1; // maybe x := old_x + 1;
y := old_y + old_x;