Share your thoughts in the 2024 State of Clojure Survey!

Welcome! Please see the About page for a little more info on how this works.

+2 votes
in Docs by
retagged by

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.

1 Answer

+1 vote
by

Logged improvement request as https://clojure.atlassian.net/browse/CLJ-2595

by
Hello Alex,

could you please take a look at the patch whenever you have a spare minute?
https://gist.github.com/etolbakov/d5a7bcbd36d3644a7cb564066cd8aa15
Sorry, for putting it that way, don't have "Attach Files" permissions in the Jira.
Happy to rework it if that's required.

--
Regards, Eugene
by
Hi, I actually can't look at the patch as we only accept patches from contributors and I try to avoid looking at anything in case I end up needing to implement something clean.

If you'd like to become a contributor and submit a patch, that would be great and you can do so with the process at https://clojure.org/dev/dev#_becoming_a_contributor
by
Thank you very much for your reply, will do it then.
...