In ClojureScript one can provide default protocol implementations as follows:
(extend-type default
AProtocol (f [] ...))
This is nicely documented in ClojureScript's extend-type
docstring:
- default, meaning the definitions will apply for any value,
unless an extend-type exists for one of the more specific
cases below.
- nil, meaning the definitions will apply for the nil value.
It may worthwhile to document how one can provide default implementations for protocols in clojure as well, by using extend-type
for Object
& nil
, on extend-type
clj docstring. On the website is documented already.