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
only.
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.
/be
Allen Wirfs-Brock <mailto:[email protected]>
September 24, 2013 8:42 AM
No, see
http://people.mozilla.org/~jorendorff/es6-draft.html#sec-12.13.2
<http://people.mozilla.org/%7Ejorendorff/es6-draft.html#sec-12.13.2>
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.
Allen
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss