Pattern Matching Syntax

Proposal: https://github.com/tc39/proposal-pattern-matching

Scope: needs to be defined

goal: identifying a syntax for pattern matching

Ongoing discussion: https://github.com/tc39/proposal-pattern-matching/issues/149, https://github.com/tc39/proposal-pattern-matching/issues/153, https://github.com/tc39/proposal-pattern-matching/issues/160

Pattern matching is an anticipated proposal and fixes some issues we have with switch statements. However the initially proposed syntax has a high cost on the syntax budget. There is room for exploration here.

Since I’ve just taken over championing this proposal, and the New champion group has not yet met, and the syntax is likely to change, it may be premature to explore things based on the initially proposed syntax (which has changed in the repo sine the presentation, significantly)

Thanks for the comment. Yes the syntax is likely to change substantially. If we want, we can use qualitative methods to identify important aspects to incorporate into the design. This is why the scope still needs to bee defined.

1 Like

What is the difference between caes-when syntax and switch-case syntax? To support destructuring cases?

Another difference is that the whens don’t fall through to the next one. So don’t need to add break.

Yes, seems like a short-circuit.