You just can't use defrecord, because defrecord macroexpands into a deftype that implements a *different* protocol with a function *also* named "get".
On Thu, Feb 7, 2013 at 9:24 PM, Don Jackson <cloj...@clark-communications.com> wrote: > > I'd like to name a protocol method to be the same name as a clojure.core > function, for example, get. > > Is this possible, and if so, how? > > user=> (ns ptest.protocol > (:refer-clojure :exclude [get])) > nil > > ptest.protocol=> (defprotocol TestProtocol > (get > [_ key] > "Returns the contents of field :key") ) > > TestProtocol > > ptest.protocol=> (ns ptest.core > (:require [ptest.protocol :as testp]) > (:refer-clojure :exclude [get])) > > ptest.core=> (defrecord TF > [a > b > ] > testp/TestProtocol > (get > [this key] > "Doesn't work!")) > > CompilerException java.lang.ClassFormatError: Duplicate method > name&signature in class file ptest/core/TF, compiling:(NO_SOURCE_PATH:1) > > > -- > -- > 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/groups/opt_out. > > -- Ben Wolfson "Human kind has used its intelligence to vary the flavour of drinks, which may be sweet, aromatic, fermented or spirit-based. ... Family and social life also offer numerous other occasions to consume drinks for pleasure." [Larousse, "Drink" entry] -- -- 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/groups/opt_out.