clj-commons

dpsutton 2022-10-19T19:29:50.237739Z

does clj-commons/potemkin’s defprotocol+ support extend-via-metadata?

dergutemoritz 2022-10-20T10:20:21.199779Z

That's the advantages of extend-via-metadata though, not of defprotocol+ right? 😄

dergutemoritz 2022-10-20T10:20:52.608099Z

IIRC the advantage of the latter is that recompilation retains the protocol's identity when possible?

dpsutton 2022-10-20T12:36:36.917689Z

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

lread 2022-10-20T13:30:14.559029Z

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.

dpsutton 2022-10-20T13:31:15.291769Z

It’s not performance. There’s a thread in #beginners about the pain right now

lread 2022-10-20T13:31:43.415909Z

Oh, thanks, I'll go check it out.

dpsutton 2022-10-20T13:32:09.679849Z

It’s in #clojure I was mistaken

lread 2022-10-20T13:35:45.071079Z

Oh.... gee, thanks, that helps! Thanks a ton @dpsutton and @dergutemoritz!

lread 2022-10-20T14:39:27.924629Z

I created an https://github.com/clj-commons/potemkin/issues/67 to describe defprotocol+ in the potemkin README.

lread 2022-10-20T14:40:26.615149Z

(and https://github.com/clj-commons/potemkin/issues/68 for import-vars)

🙏 1
dpsutton 2022-10-19T19:35:05.271029Z

appears that it can

lread 2022-10-19T21:48:19.134719Z

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.

dpsutton 2022-10-19T22:48:08.816689Z

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 map

dpsutton 2022-10-19T22:51:03.086269Z

otherwise i’d need to make a defrecord, have it implement the model dispatch stuff, etc

dpsutton 2022-10-19T22:51:15.206639Z

and just for a simple test i don’t want records and a bunch of junk