Deconstructing assignment and reader/modify/write operands

Brendan Eich 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 
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:allen at wirfs-brock.com>
> 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
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss


More information about the es-discuss mailing list