3 ms·
I don't see a huge benefit for pattern matching in JS outside of it being expression based rather than statement based. Either way, the benefit has to be enorm
by dgb23 4y ago
I don't see a huge benefit for pattern matching in JS outside of it being expression based rather than statement based.
Either way, the benefit has to be enormous. It's a feature that can easily break existing code.
- baq 4y agoIn a world where upgrading node versions without language changes breaks existing code I wouldn’t be too worried.
- int_19h 4y agoHow would it break existing code?
- dgb23 4y agoBecause it is an expression that introduces a new keyword. You could say “return match…” It’s not easy to introduce without breakage. Not saying it cannot be done. But PHP didn’t manage to for example. It also isn’t real pattern matching but that’s a different issue.
- int_19h 4y agoOh, so you were referring to the specific syntax in the current proposal, rather than pattern matching in general? Java and C# show how the syntax can be done in a fully backwards-compatible manner. It looks like it's just not the JS way by choice - apparently every new keyword that was added since ES5 is an actual keyword reserved in all contexts, not context-dependent?
- dgb23 4y agoThat’s good to hear!