Deconstructing assignment and reader/modify/write operands

Oliver Hunt oliver at apple.com
Tue Sep 24 11:46:39 PDT 2013


I'll try to rephrase:

As I read the spec this is not a syntax error, and so gets delayed to runtime.  Given that we're already doing work to determine whether we should be destructuring (which results in different runtime semantics), it seems we should promote (demote?) <deconstructing lhs> <rwm operator> <expression> to a syntax error -- it seems like it would be an easy typo to make so detecting it earlier would seem a plus.

FWIW I'm not sure I agree with brendan on this idea being a misfeature, but I think we really should try to make it at least an early error.

--Oliver

On Sep 24, 2013, at 11:33 AM, Brendan Eich <brendan at mozilla.com> wrote:

> 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