Fork me on GitHub
#clojure-uk
<
2020-09-07
>
dharrigan06:09:00

Good Morning!

seancorfield06:09:08

Happy Monday! 🙂

djm07:09:12

👋

dharrigan09:09:52

Well today I learnt something new. You can redefine a defmethod. I always thought you couldn't as I understood multimethods were cached and un-redefinable.

rickmoynihan10:09:11

You can redefine them if you use clojure.tools.namespace’s refresh / clear etc. Also you can also do so manually by just (def mymulti nil) then re-eval the defmulti and defmethods you want. Also remove-method and remove-all-methods

dharrigan16:09:45

thank you 🙂

dharrigan09:09:00

But, if I understand now, it's the dispatch function that cannot be changed. However, I see there is a little trick to use a reference to a function which does the dispatching, wihthin the defmulti

Ben Hammond14:09:38

you can blat the defmulti and redeclare it

Ben Hammond14:09:20

but you cannot just redeclare overwrite it because there is a defonce squirreled away inside, and it will just ignore you

dharrigan16:09:40

thank you 🙂

Jakob Durstberger14:09:58

Morning 👋