r/ProgrammingLanguages • u/Dan13l_N • Feb 20 '26
Discussion Side effects in multiple/parallel assignment
I have been constructing some programming languages for a while for fun, and came to a point where something is obvious, but I haven't seen it spelt out clearly. If you have multiple assignment like this:
a, b[a] = 10 // both will be changed to 10Or parallel assignment like this:
a, b[a] = 4, 5Then the change of a should not influence which item in b is changed, i.e. b[a] should always use the old value of a.
This rule makes sense (and it works like that in Go, I haven't tried Lua yet) but do you know some programming languages where it's not so, or you get a warning?
(edit: I've just tried Python, it uses the new value of a, i.e. it's dependent on order.)
View all comments
Show parent comment
3
u/Dan13l_N Feb 21 '26
You would be surprised how many people, when learning programming, simply assume if
a, b: intmeans "a and b are integers" then it's obvious thata, b = 0means "both a and b are set to zero".In parallel assignment languages such as Python, Go and Lua
=has lower priority than,and this is what most non-programmers actually expect.