Closed Jack-Works closed 2 years ago
Maybe I should remove this part from this PR? And... any review or approval?
Why would we remove that part?
Why would we remove that part?
The syntax I quoted is not in the pattern matching, but in the destructing, which means it allows you to write the following code:
const ${ Some } with Item = result
oh, yeah that's definitely wrong :-)
(i'm not the best person to review syntax/grammar; so all i can do is ask about the implications)
I added it just for the symmetry (cause PM has that). Anyone I'll wait for more comments (to remove it or keep it).
Pattern matching needs to mimic destructuring, but the reverse is very much not true. Patterns shouldn't work in destructuring, and ${}
only works inside a template literal or inside a pattern context.
Another backport is ...
. Should we bring const [a, ...] = b
back to the deconstructing? ( cc @hax that have a proposal about iterators )
No, there's no reason to add it, because destructuring doesn't check the length.
I have removed the backport part.
😂 since there is no review for months, I guess I can merge this first. If there is any problem, we can always open a new PR to fix it. This also allows future specifications of EE and RS.
Only contains the syntax. Hope Early Errors and RS can be deferred to future PRs.
Note
undefined
,NaN
andInfinity
are covered by theIdentifierMatchPattern
, but+Infinity
and-Infinity
are coverd by theNearLiteralMatchPattern
.Initializer
is allowed in the current syntax. See https://github.com/tc39/proposal-pattern-matching/#default-values