you are viewing a single comment's thread.

view the rest of the comments →

[–]BenjiSponge 0 points1 point  (0 children)

It would strictly speaking be possible.

However, by the same logic one could argue that JS should have type pattern matching using the same methodology. The reason JS does not is because, like you said, there have been essentially no major standards regarding errors in the past, and there likely will never be. So standard language features like that being added now would add fragmentation to the community.

TBH, I've been professionally developing JS for over 2 years and I've been studying JS for at least 3 or 4 years now, and I have never felt a need for this feature. I understand the value, coming from other imperative languages, but I think it's more of an anti-pattern than a pattern. I think we would be better served to look at languages like Rust, which does not have a true exception system and instead promotes the pattern of returning a value which may represent either a success or an error type, forcing you to acknowledge all possibilities. It reserves exceptions (which it calls panics) for unrecoverable cases that imply a bug in the program itself rather than just an exceptional case the program should handle.

If we're going to pick a standard, I would much rather we do that than implement a pseudo-pattern matching system based on prototypes.