Deconstructing assignment and reader/modify/write operands
brendan at mozilla.com
Tue Sep 24 11:33:11 PDT 2013
Oliver may be asking "why?" The reductiionistic answer is because L += R
is evaluated as if by L = L + R but with L evaluated to a Reference once
The deeper question (if I may stand in for Oliver) is why wouldn't we
want some nicer new semantic for [a, b] += [c, d] -- a "parallel
add-and-assign." We could do that, but it would deviate from the
straightforward meaning of the assignment operators composed with
destructuring, by quite a bit.
When composing two things leads to an unexpected result, there's a
smell. It could be handy, but it's probably better off done with a
distinct special form.
> Allen Wirfs-Brock <mailto:allen at wirfs-brock.com>
> September 24, 2013 8:42 AM
> No, see
> Destructuring is only checked for in the LHS = RHS case.
> The LHS AssignmentOperator RHS case is just like ES5 and doesn't do
> any destructuring.
> es-discuss mailing list
> es-discuss at mozilla.org
More information about the es-discuss