Forgive me for taking so long to reply to your very informative feedback. Only this evening have I had time to experiment and study. These are my findings so far:
'defprotocol' is a macro with side-effects, so any attempt at holding on to a copy and then re-inserting it into the var in the other namespace are futile. Even worse, 'reify' is also a macro with side-effects. The side-effects seem to be that they emit (byte-)code, and then one builds on the current instance of the others emitted code. A fun hack would have been to insert a reader-macro which would prevent specific macros to run a second time by simply removing them at read-time. But alas, Clojure does not (yet) support insertion of reader-macros. But, it seems that if your call the instance-method stead of the protocol-method by the same name on your defonce-ed object, then everything works fine: (.protocol-function object) ;; do (protocol-function object) ;; don't. However, since these calls are often wrapped in a second layer of functions, then either calling the protocol-method directly (as an instance-emthod), using your own copy of the calling function will have to be the work-around. In the case of core.async/mult: (.untap-all* saved-mult-instance) ;; do (defn my-untap-all [mult] (.untap-all* mult)) (my-untap-all* saved-mult- instance) ;; do (untap-all saved-mult-instance) ;; don't On Saturday, November 14, 2015 at 11:01:20 PM UTC+1, James Elliott wrote: > > If I understand what you’re saying, then it sounds like you are reloading > a protocol definition, which creates a new protocol with the same name as > the old protocol, but they are different things. Old objects which > implement the old protocol do not implement the new protocol, even though > it looks identical and has the same name. This kind of issue has bit me > when working in iterative development on files, so I tend to protect my > protocol definitions inside defonce forms, so they do not get redefined > when I reload the file. It looks awkward, but helps. The example which > inspired me to do this was in Overtone: > > https://github.com/overtone/overtone/blob/master/src/overtone/music/rhythm.clj#L7-L28 > > -James > > On Friday, November 13, 2015 at 2:50:10 PM UTC-6, Terje Dahl wrote: >> >> I put a core.async/mult instance in a map structure in a map. >> When i do load-file ... (from La Clojure in IntelliJ) the structure with >> the object instance is still there, but it isn't possible to use. >> I get: >> >>> CompilerException java.lang.IllegalArgumentException: No implementation >>> of method: :tap* of protocol: #'clojure.core.async/Mult found for class: >>> clojure.core.async$mult$reify__7262 >>> >> >> Is this something to do with core.async itself, or perhaps a more general >> issue with protocol? >> Any thoughts? >> > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.