IPersistentMap is an interface, which are sort of the java analog of protocols, and in fact last I checked protocols generate named java interfaces, so I think you're fine
On Fri, Aug 13, 2010 at 5:10 PM, Brenton <bashw...@gmail.com> wrote: > Greetings, > > Suppose that I create a function that is designed to receive a map as > a parameter: > > (defn add-ten [m] > (+ 10 (:amount m))) > > but then later I want to make this function part of a protocol > > (defprotocol AddTen > (add-ten [this])) > > but I still want it to work when someone passes a plain map to add- > ten. The only thing that I can think of would be the following: > > (extend-protocol AddTen > clojure.lang.IPersistentMap > (add-ten [this] (+ 10 (:amount this)))) > > It feels wrong to refer to clojure.lang.IPersistentMap as if I am > relying on an implementation detail. Is there a better way to do > this? > > I'm in the middle of writing blog post about protocols (in order to > improve my own understanding of them) where I try to illustrate the > point that you can code against maps then switch to protocols and > records without changing the caller's contract. > > Thanks for your help, > Brenton > > -- > 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 -- And what is good, Phaedrus, And what is not good— Need we ask anyone to tell us these things? -- 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