destructuring: as patterns?

Brendan Eich brendan at
Fri Apr 20 09:18:31 PDT 2012

Andreas Rossberg wrote:
> On 20 April 2012 17:12, Brendan Eich<brendan at>  wrote:
>> But is it unthinkable to have 'as' (compositional of course) in the
>> pattern language only?
> Perhaps, but what exactly do you mean? ;)

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.


More information about the es-discuss mailing list