destructuring: as patterns?

Andreas Rossberg rossberg at
Fri Apr 20 11:05:01 PDT 2012

On 20 April 2012 18:18, Brendan Eich <brendan at> wrote:
> Patterns can have custom grammar in binding contexts (after let, in catch
> heads, etc.), whereas in an assignment expression's left-hand side we'd need
> ObjectLiteral and ArrayLiteral to cover the grammar.
> I sense trouble trying to add 'as' to the expression grammar
> (AssignmentExpression to be precise). We could parse it and reject it with
> supplemental syntax for rvalues, and allow it in lvalues, but there is a
> "spec smell". I think from past discussions that TC39 wants the grammar to
> be as precise as possible while still LR(1) with lookahead and other
> restrictions.

I see, I haven't thought of destructuring assignment. Yes, that's a
bit of an annoyance. But IMHO not a big issue either. Honestly, my
feeling is that strictly sticking to that principle will overly
constrain pattern syntax anyway, if not for 'as' then for the next
nice feature. I dimly remember that we had it coming up before.

One alternative of course would be to restrict what can occur in an
assignment pattern, compared to bindings. The two are quite different
semantically, so it could perhaps be argued. But it's not the most
pleasant idea either.


More information about the es-discuss mailing list