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

0 votes
in REPL by

user=> (source clojure.core.protocols/coll-reduce) Source not found

But since the protocol fn's var's metadata points to the protocol var, and the protocol var knows the file and line where it was defined, it would be trivial to improve 'source' to look like this:

user=> (source clojure.core.protocols/coll-reduce) (defprotocol CollReduce "Protocol for collection types that can implement reduce faster than first/next recursion. Called by clojure.core/reduce. Baseline implementation defined in terms of Iterable." (coll-reduce [coll f] [coll f val]))

3 Answers

0 votes
by

Comment made by: chouser@n01se.net

Add one-line patch to clojure.repl/source so that it will find the protocol definition for a given protocol function.

0 votes
by

Comment made by: jafingerhut

Patch 0001-Add-support-for-protocol-fns-to-repl-source.-CLJ-1088.patch no longer applies cleanly as of commits made to Clojure master on Jan 31 2014, probably due to the patch for CLJ-1176. I have not investigated how easy or difficult it would be to update.

0 votes
by
Reference: https://clojure.atlassian.net/browse/CLJ-1088 (reported by chouser@n01se.net)
...