-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
relationship with pattern-matching proposal #1
Comments
I'd personally block any attempt to improve or alter |
@ljharb const color = (type) => ({
apple: "red",
banana: "yellow"
}[type] ?? "invisible"); Much more compact, much more maintainable. If the underlying mapping object (or a proper If this |
Note Java/C# all improve and provide a better |
I think JavaScript can aim much higher than matching Java or C#. |
Pattern matching is the better version of |
In C#, better |
I am confused why we should always put JS to the position opposed to other successful mainstream languages like C#/Java. Of course, we do not need to copy feature just for make JS look like Java/C#, but we also does not need to always refuse adopt a similar design in order to make JS look different from Java/C#. Especially If it is not a careful examination of the pros and cons of various solutions, but a priori assertion that a certain design must be rejected, in my opinion it's an irresponsible arrogance. |
I didn't make this proposal trying to compare JS with other languages, I feel good with JS and I think it is one of the languages that gives the best user experience. The origin of this was that I spent almost a year working with Kotlin, until I finally went back to JS (where I feel much more comfortable). In this return I realized that I missed some things from Kotlin that I found intuitive and compatible with the JS mindset but that we didn't have. Among them a way to return values from the Switch, or even from a try/catch. I base this on the feeling that it is something to be expected (the return), that it would have an instant adoption and without generating confusion about its use. It simply makes it easier to read the code and to understand the origin of the value assigned to a variable. I think async/await went that way and had very good repercussions. |
@hax you're exactly right that they’re not opposed, and that we should always consider what other languages have done - but that doesn’t mean “matching another language” should be a justification for anything in and of itself. @gmarcos87 my opinion is that it’s impossible to use any form of switch and not have confusion about its use. I consider that well irrevocably poisoned. |
It seems it can be well achieved via pattern matching
So probably pattern matching is a way to go since it's more powerfull in all the aspects |
https://github.com/tc39/proposal-pattern-matching
The text was updated successfully, but these errors were encountered: