Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I mean depending on what you mean by "have", yes? But also that's been true since the 90s. Out of the box, less so. Clojure has destructuring assignment, but no matching. A lot of little lisps downstream of Clojure (Janet, Fennel I think) do have matching, though not for function calls. I think that destructuring is most of the value add of pattern matching for me- that's not to say matching isn't great, just that destructuring is such a no-brainer value add that its hard to compete with. I do find myself missing the {:error, ...}, {:ok, ...} pattern in other languages. Nil punning doesn't give you anything close to as much, and at significant cost.

For pipes, the answer is definitely yes though. Clojure has arrow macros, which let you compose without nesting just like Elixir.

  (->> [1 2 3] (map inc) (filter even?) (reduce +)) => 6
There's one for threading through the first argument, and another for threading through the last, and various others for specific situations. Because they're pretty simple macros to write, I also use similar macros extensively in my CL code. In fact, I actually learned CL after getting used to Elixir so the first entry to my utilities package was a threading macro.


I think Clojure has benefited from matching being kept out of the built-in stdlib. https://github.com/clojure/core.match is a plug-in and as a result we've had lots of cool data traversal/matching DSLs come around and evolved user communities with time such as Meander and Datascript not to mention the parsing applications of the schema systems (spec & malli).


Meander and Specter make Clojure a lot nicer to use day-to-day.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: