Why assignment operators return the right-hand-side

No, I was just wrong about that. How would you assign a semantics to b in an expression like (a = b) = c? b is meaningless before c is evaluated.

One might want a syntax like that in a language where the normal return value of assignment is the left side, but that wouldn’t make things truly left associative.

There’s a reason mathematicians dislike = for assignment, assignment has none of the properties of equality suggested by the symbol.

1 Like