does clj-commons/potemkin’s defprotocol+ support extend-via-metadata?
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.
It’s not performance. There’s a thread in #beginners about the pain right now
Oh, thanks, I'll go check it out.
https://clojurians.slack.com/archives/C03S1KBA2/p1666247372091009
It’s in #clojure I was mistaken
Oh.... gee, thanks, that helps! Thanks a ton @dpsutton and @dergutemoritz!
I created an https://github.com/clj-commons/potemkin/issues/67 to describe defprotocol+ in the potemkin README.
(and https://github.com/clj-commons/potemkin/issues/68 for import-vars)
appears that it can
I never really understood the advantages of potemkin’s defprotocol+. Do you have a good grasp on the advantages @dpsutton? 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
and just for a simple test i don’t want records and a bunch of junk