Hacker News new | comments | show | ask | jobs | submit login

This is the pattern matching library described here: http://news.ycombinator.com/item?id=2864482

match is not a Clojure primitive. match is macro that is an optimizing pattern match compiler. It works on all of Clojure's data structures.

The problem is that for things which are not Clojure data structures - primitive arays and bytes - how do you pattern match those without introducing overhead? Enumerating all the possibilities is out of reach. Adding an abstraction means introducing some kind of wrapper type - ridiculous performance loss when you dealing with primitive arays and byte.

So you can derive the compilation procedure (::match.core/vector, here shortened to ::m/vector) and specify what code to put in the critical locations. Instead of subclassing objects, we're "subclassing" the compiler algorithm and saying put in this code if the match expression has annotations like ::int.

The result is that we can match arrays 30 times faster than Scala, 10 times faster than Racket. And we have bit level pattern matching a la Erlang in what ... 10 lines of code?




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

Search: