Multimethods are one of Clojure’s primary polymorphism mechanisms. They allow dispatch on an arbitrary number of arguments, by combining a dispatching function with one or more methods. Here’s a way to implement them.
After reading Alexis King’s post about ADT’s in Typed Racket, I felt inspired to try the same thing in Clojure.
I’ve been working on my first general purpose programming language last week, guided by the books SICP and Write Yourself a Scheme in 48 Hours. This has been a goal of mine for a long time, but it somehow always looked intimidating. I was glad to find out that interpreters can actually be astonishingly simple, and would like to share what I learned along the way.