This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-10-19
Channels
- # adventofcode (1)
- # announcements (3)
- # babashka (60)
- # beginners (60)
- # calva (5)
- # clj-commons (17)
- # clj-kondo (33)
- # clj-on-windows (1)
- # clojure (40)
- # clojure-austin (3)
- # clojure-europe (19)
- # clojure-gamedev (25)
- # clojure-nl (1)
- # clojure-norway (6)
- # clojure-sweden (4)
- # clojure-uk (2)
- # clojurescript (27)
- # conjure (1)
- # core-async (1)
- # core-typed (7)
- # cursive (5)
- # datomic (35)
- # events (1)
- # fulcro (35)
- # integrant (7)
- # introduce-yourself (2)
- # kaocha (5)
- # leiningen (2)
- # lsp (26)
- # malli (13)
- # nbb (99)
- # off-topic (15)
- # pathom (12)
- # pedestal (5)
- # polylith (8)
- # portal (4)
- # rdf (19)
- # reagent (8)
- # reitit (5)
- # releases (2)
- # remote-jobs (2)
- # rewrite-clj (1)
- # shadow-cljs (94)
- # testing (2)
- # timbre (2)
- # tools-deps (16)
I never really understood the advantages of potemkin’s defprotocol+
. Do you have a good grasp on the advantages @U11BV7MTK? And if so, can you enlighten my poor wee brain.
It does work. We have some records that serve as models. And a mechanism that checks a notion of can-read?
. And this can depend on the collection that entities are in , and gets very domain-y.
But there’s a protocol for things to identify as a model and if i can extend it by protocol then
(with-meta {:id 1 }{`models.dispatch/model
(fn [_] ::dispatches-on-dynamic)})
a simple map like {:id 1}
can report it is a model and then i can sub out what can-read?
means for a simple mapotherwise i’d need to make a defrecord, have it implement the model dispatch stuff, etc
That's the advantages of extend-via-metadata
though, not of defprotocol+
right? 😄
IIRC the advantage of the latter is that recompilation retains the protocol's identity when possible?
Oh good point. I misread which part the question was about. Yeah it’s basically a defonce on a protocol that is aware when it needs to recompute
Ah thanks! So a performance concern, ya? Do you know of any existing benchmarks of defprotocol
vs defprotocol+
? I'm a bit curious, your mention of it here surfaced a memory of me replacing defprotocol+
with defprotocol
it when moving to cljc for rewrite-clj v1.
Oh.... gee, thanks, that helps! Thanks a ton @U11BV7MTK and @U06GVE6NR!
I created an https://github.com/clj-commons/potemkin/issues/67 to describe defprotocol+
in the potemkin README.