The right way to do this is the way Prolog does it.
It doesn't matter if you say VAR = 12
or 12 = VAR or 1,2,10 = A, B, C
It does whatever it takes to make the left and the right sides equivalent to each other.
foo = 1
bar = 2
foo = bar
?- FOO = 1,
BAR = 2,
FOO = BAR.
false. ?- FOO = BAR, FOO = 1, print(BAR).
1 ?- FOO = 1,
BAR = 1,
FOO = BAR.
FOO = BAR, BAR = 1.