Hi Neils,
If I've understood you correctly, can you just redefine the protocol
implementation for Associative? E.g.
(defprotocol ProtX
(do-thing [x]))
=> ProtX
(extend clojure.lang.Associative
ProtX
{:do-thing (fn [x] (str/lower-case (get x :a-val)))})
=> nil
(do-thing {:a-val "Some String"})
=> "some string"
(extend clojure.lang.Associative
ProtX
{:do-thing (fn [x] (str/upper-case (get x :a-val)))})
=> nil
(do-thing {:a-val "Some String"})
=> "SOME STRING"
On Thursday, March 24, 2016 at 10:14:11 PM UTC+13, Niels van Klaveren wrote:
>
> In a project using clojure.java.jmx, I was extending it's Destract protocol
> object->data function to transform more of the JMX data structures
> returned from calls or metadata queries into plain clojure data structures.
> When I was done with the individual data structures, it should have been
> possible to do a (walk/prewalk jmx/objects->data (jmx/operations
> "java.lang:type=Threading")).
>
> However, in the Destract protocol there's an implementation of the
> objects->data function for the type clojure.lang.Associative that would
> mean maps would be processed incorrectly. I could add an implementation for
> clojure.lang.IPersistentMap in my namespace, but since
> clojure.lang.Associative is also an interface for maps this would not
> work, and I ended up having to fork clojure.java.jmx because of it. If
> there would be a way to retract a protocol for a type within another
> namespace I wouldn't have had to. Is there such a way, or would it even be
> feasible to implement something like it?
>
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
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 [email protected].
For more options, visit https://groups.google.com/d/optout.