So if I do this in a clean REPL Clojure 1.2.0 user=> (defprotocol Foo (bar [this x])) Foo user=> (defrecord fooed [] Foo (bar [this x] (* 2 x))) user.fooed user=> (defprotocol Foo (bar [this x])) Foo user=> (extend-type Object Foo (bar [this x] (/ 2 x))) nil user=> (def fooey (fooed.)) #'user/fooey user=> (bar fooey 10) 1/5 user=> (defrecord fooed [] Foo (bar [this x] (* 2 x))) user.fooed user=> (def fooey (fooed.)) #'user/fooey user=> (bar fooey 10) 20
I would have expected 20 the first call to bar to be 20. This is a natural sequence of lines to execute if you---for instance--- have Foo defined in file A and fooed in file B, and you then add a default implementation using extend-type in file A and then recompile file A. This scenario is easily fixed by recompiling file B (as the last few lines demonstrate). I don't see any easy way to actually fix this behavior (though my understanding of how protocols are implemented is largely based on seeing how they behave and my limited knowledge of the JVM, rather than actually looking at the code), but it does seem like it would be less surprising if it could be accomplished. Thoughts? Should I post this as a ticket in assembla? -- 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