Fork me on GitHub
#clojure-dev
<
2020-09-14
>
andy.fingerhut16:09:44

If this is considered a bug in Clojure's primitive vector implementation, it seems like perhaps a harmless one, but thought I would ask anyway in case I learn something new. See thread for details.

andy.fingerhut16:09:25

There is a print-method in gvec.clj with a dispatch value of ::Vec, whereas I would have expected the dispatch value to be the class clojure.core.Vec: https://github.com/clojure/clojure/blob/master/src/clj/clojure/gvec.clj#L455

andy.fingerhut16:09:39

It seems that this print-method is not called for Clojure primitive vectors, at least not normally:

user=> (= (get-method print-method [1 2 3])
   (get-method print-method (vector-of :byte 1 2 3)))

true

andy.fingerhut16:09:58

Given the definition of the multimethod print-method's dispatch function, it seems like that print-method in gvec.clj would get called for any object that had metadata with a :type key whose value was :clojure.core.Vec , but I can't think of any reason why that would happen unless someone went out of their way to arrange it.

andy.fingerhut16:09:12

I suspect that this is intentional for reasons I haven't figured out, or it is a bug that no one has noticed because calling print-method on a clojure.core.Vec will already call the same method as for regular Clojure vectors, and that is what the print-method definition in gvec.clj appears to be trying to do, anyway, if it were used.

Alex Miller (Clojure team)17:09:35

dunno, feel free to file a jira