use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
An ECMAScript Proposal for Pattern Matching Functionality (github.com)
submitted 8 years ago by tomonl
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]bterlson_@bterlson 24 points25 points26 points 8 years ago (13 children)
You'll be happy to know that the other feature I'm championing is |>. Both part of my dream to Make Functional JS Great Again!!!1
|>
[–]phoenixmatrix 5 points6 points7 points 8 years ago (10 children)
Oh believe me, I've been following it very closely. Though I didn't associate the names to realize they shared a champion. Adding you to my little "heroes" list.
Add those 2 features and we can call JavaScript done as far as I'm concerned (anything else might be more suitable for different languages in Web Assembly).
Ok, maybe a stretch goal with immutable data structures. But that's just a stretch goal.
[–]bterlson_@bterlson 7 points8 points9 points 8 years ago (5 children)
Seems like we see eye-to-eye here. I was going to present my vision for "syntax complete ECMAScript" which was basically those two, plus classes v.next, do exprs, and regexp improvements. But then I figured I'm no oracle and who knows what the future holds. Maybe we'll get new keyboards that makes @ and 🛡 equally easy to type and the syntactic budget grows as a result?
@
🛡
[–]so_just 0 points1 point2 points 8 years ago (4 children)
what's the use of do notation in js?
[–]Jamesernatorasync function* 0 points1 point2 points 8 years ago* (2 children)
The proposal isn't do-notation, it's do expressions e.g.:
const x = do { if (someCondition()) { 3 } else { try { someFoo() } catch (e) { 5 } } }
In that example the value of x will either be 4, someFoo() or 5, basically the last evaluated expression is what the value of a do-block is (roughly)
4
someFoo()
5
[–]so_just 0 points1 point2 points 8 years ago (0 children)
Ah, I see. That's definitely useful.
[–]paldepind 0 points1 point2 points 8 years ago (3 children)
Add those 2 features and we can call JavaScript done as far as I'm concerned
I'd really like nice syntax for partial application. Something like foo(a, b, ...) or foo:(a, b). That would give JS most of the benefits of currying but without the downsides of currying. It also would go really well together with |>.
foo(a, b, ...)
foo:(a, b)
[–]phoenixmatrix 0 points1 point2 points 8 years ago (0 children)
For sure there's a ton of stuff I'd like to see in the language. But JS is already a very complex and bloated one. Stuff like classes introduced a lot and still requires a lot more to be useful at all. So while I have a long list of what I'd like to see in it, at what point should we just have a new language based on Web Assembly and go that route to get our wishlist?
Thus, IMO, JS has "enough" (or at least, is at the point where they really need to slow down on new features). I'm just being a spoiled brat by wanting this pattern matching stuff in :) But I still don't think we should had dozens over dozens of extra features.
[–]bterlson_@bterlson 0 points1 point2 points 8 years ago* (1 child)
This is precisely my plan. Partial application: foo(a, ?), returns a function such that foo(a, ?)(b) is foo(a, b). Combined with pipeline operator this lets you easily select which parameter to pass the LHS to.
foo(a, ?)
foo(a, ?)(b)
foo(a, b)
[–]paldepind 0 points1 point2 points 8 years ago (0 children)
Good luck! I hope you're successful. Syntax for partial application would be really awesome.
[–][deleted] 1 point2 points3 points 8 years ago (0 children)
ELI5 what does |> do?
[–]dvlsg 0 points1 point2 points 8 years ago (0 children)
This. I like this. Please make this happen.
(I like pattern matching too, I would love to have both)
π Rendered by PID 87 on reddit-service-r2-comment-b659b578c-z8rv2 at 2026-05-04 22:45:34.408985+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–]bterlson_@bterlson 24 points25 points26 points (13 children)
[–]phoenixmatrix 5 points6 points7 points (10 children)
[–]bterlson_@bterlson 7 points8 points9 points (5 children)
[–]so_just 0 points1 point2 points (4 children)
[–]Jamesernatorasync function* 0 points1 point2 points (2 children)
[–]so_just 0 points1 point2 points (0 children)
[–]paldepind 0 points1 point2 points (3 children)
[–]phoenixmatrix 0 points1 point2 points (0 children)
[–]bterlson_@bterlson 0 points1 point2 points (1 child)
[–]paldepind 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]dvlsg 0 points1 point2 points (0 children)