Playing a little fast and loose with the metagrammar, I think this proposal should be simplified to
A.1 Expressions
The main change is how the distinction between comparing against values is expressed vs how bindings are introduced. The existing proposal treats a bare Identifier as a lexical reference to a variable from the enclosing scope, so it introduces bindings with a let, const, or var prefix. This is not at all like destructuring. IMO people will be confused by this asymmetry.
I saw in the proposal a suggestion of a pattern to be able to start with a (normally binary) relational operator followed by an expression. This is the opportunity to restore the symmetry with destructuring! This gives a way to introduce expressions whose value can be compared, including expressions using variables from outer scopes. Any Identifier appearing normally in a pattern is binding occurrence, just as one expects from destructuring.
Playing a little fast and loose with the metagrammar, I think this proposal should be simplified to
A.1 Expressions
PrimaryExpr:
RelationalExpr: // unchanged, but useful below
<|<=|>=|>) ShiftExprinstanceof|in) ShiftExprEqualityExpr:
==|!=|===|!==) RelationalExpr~=MatchPattern // like the proposedisMatchPattern:
void// I'm a fan, and allows...void=AssignmentExpr // can we make defaults this simple?[(MatchPattern,)* (...MatchPattern)?]{(Prop:MatchPattern,)* (...MatchPattern)?}andMatchPattern // consider&&?orMatchPattern // consider||?notMatchPattern // consider!?if(Expr)<|<=|>=|>) ShiftExpr===|!==) RelationalExpr~=MatchPatternLeft-Hand-Side Exprs: // enhance destructuring
void~=MatchPattern // refutableThe main change is how the distinction between comparing against values is expressed vs how bindings are introduced. The existing proposal treats a bare
Identifieras a lexical reference to a variable from the enclosing scope, so it introduces bindings with alet,const, orvarprefix. This is not at all like destructuring. IMO people will be confused by this asymmetry.I saw in the proposal a suggestion of a pattern to be able to start with a (normally binary) relational operator followed by an expression. This is the opportunity to restore the symmetry with destructuring! This gives a way to introduce expressions whose value can be compared, including expressions using variables from outer scopes. Any
Identifierappearing normally in a pattern is binding occurrence, just as one expects from destructuring.