Skip to content

Instantly share code, notes, and snippets.

@cjohansen
Created August 31, 2019 07:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cjohansen/a24257ecb5db15c7e20aaa25ff713b30 to your computer and use it in GitHub Desktop.
Save cjohansen/a24257ecb5db15c7e20aaa25ff713b30 to your computer and use it in GitHub Desktop.
(defprotocol ExtMetaProtocol
:extend-via-metadata true
(ext-meta-protocol [x]))
(ext-meta-protocol (with-meta {} {`ext-meta-protocol (fn [_] 1)})) ;;=> 1
(extend-type clojure.lang.PersistentArrayMap
ExtMetaProtocol
(ext-meta-protocol [m]
2))
(ext-meta-protocol {}) ;;=> 2
(ext-meta-protocol (with-meta {} {`ext-meta-protocol (fn [_] 1)})) ;;=> cljs => 2, clj => 1
@jafingerhut
Copy link

Confirmed that Clojure 1.10.1 and ClojureScript 1.10.520 (at least with Node.js runtime) behave differently from each other in the way described above. For cljs the extend-type form must have clojure.lang.PersistentArrayMap replaced with the cljs equivalent cljs.core.PersistentArrayMap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment