Thanks to all of you who responded. So, I think my original thesis was correct: I'm clearly misconstruing something quite fundamental here ;)
And I can see now my original example was clumsy: for example something like PrettyPrintable *should* be an orthogonal protocol to Node. (Not to mention the example I had in mind was actually a tree not a graph :/) Anyway, to either clarify, or further muddy, the waters here's another scenario, for an actual graph library this time, assuming you'll indulge me further. --- ;; A node has a data attachment and (possibly) out-edges (defprotocol Node (data [n]) (out-edges [n])) ;; A client's implementation of Node using library 1.0's protocol (deftype SimpleNode [d] Node (data [n] d) (out-edges [n] [])) ;; In version 2, I decide nodes may also report their in-edges. I'd ;; actually like to add "in-edges" to Node, but can't because that ;; would break existing clients. (defprotocol Node2 (in-edges [n])) ;; A client's new type of node using library v 2.0's protocols (deftype SimpleNode2 [d in out] Node (data [n] d) (out-edges [n] out) Node2 (in-edges [n] in)) ;; Now, if I want any node's in-edges, I can't just call "in-edges" ;; because Node implementations won't have it, so I compute them in ;; that case. (defn node-in-edges [n] (if (isa? Node2) (in-edges n) (compute-node-in-edges n))) ;; OR, I could use extend-type to allow in-edges to be called on ;; anything, and use a default implementation for Node's. (extend-type Object Node2 (in-edges [n] (if (isa? Node) (compute-node-in-edges n) (<throw an exception?>)))) --- In contrast, if I could have added in-edges to Node in v 2.0, with an accompanying default implementation for existing clients, then I could have saved quite a lot of messing about. Am I still on the wrong track here? Matthew. -- 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