An aspect-oriented library for Clojure
Most aspect-oriented patterns I have seen in Clojure work one of two ways: first, via rebinding var roots dynamically; or second, via functional composition. While both of these patterns are perfectly adequate for many use cases, they are not (IMO) perfect solutions for all. If I wish to avoid dynamic rebinding or if I do not wish to eschew built-in language/tooling features (fn arglist metadata, docstrings, etc.), then typical patterns won't work.
The following library provides an extension to Clojure's built-in `defn` form that allows you to tag your function definitions with compile-time macro transformations. It also provides very simple macro constructors for the most common use cases. It's not intended to replace
dynamic decorations or
functional composition, but to provide another useful tool in the box. The library's motivation is explained with a simple example
here, and a more detailed comparison with other Clojure idioms is found
here.
I've quite enjoyed building and using this library over the last few years, and I hope others can find it useful as well! I recently updated it to work with Clojurescript (but not self-hosted Clojurescript). This was an adventure, and it's quite possible there are some issues with the CLJS implementation that I have not yet discovered.
~Timothy Dean