Fork me on GitHub
#clojure-uk
<
2022-02-07
>
dharrigan07:02:32

Good Morning!

Aron08:02:50

I know nothing about extend via metadata

mccraigmccraig11:02:58

i think i've used :extend-via-metadata only once, when i had an existing protocol-based codebase and needed to dynamically compose some components to satisfy a protocol... my recollection is that :extend-via-metadata made life a lot easier, but i was never faced with the "or use a multimethod" choice because existing codebase

dharrigan12:02:41

My interpretation is :extend-via-metadata is useful for libraries (that look for that) and/or tooling.

seancorfield18:02:24

The nice thing about :extend-via-metadata is that you can provide implementations on an ad hoc basis, just by attaching metadata to a Clojure object. This is common with datafy/`nav` for example, and we do it with Component at work quite a bit (attaching start/`stop` implementations to hash maps or functions, instead of using defrecord for some lifecycle).

seancorfield18:02:52

So you don't need to define anything, no defrecord, no defmethod.