(defprotocol XmlNode
  (as-xml [this]))

(defrecord User [^Integer id ^String name ^java.util.Date dob])

(def a '(as-xml [this] (str this)))

(eval (backtick/template (extend-protocol XmlNode
  Integer
  ~a
)))

I've no experience with these, so that's off the top of my head...

backtick is https://github.com/brandonbloom/backtick


or maybe like this:

(defprotocol XmlNode
  (as-xml [this]))

(defrecord User [^Integer id ^String name ^java.util.Date dob])

(def a '(as-xml [this] (str this)))

(defmacro x [wha]
  `(extend-protocol XmlNode
     Integer
     ~(eval wha)
     )
  )

(x a)


On Saturday, February 23, 2013 1:03:02 PM UTC+1, Jim foo.bar wrote:
>
> I seem to be unable to quote a form and then repeatedly pass it inside 
> the extend-protocol macro...something like this: 
>
> (def ^:private co-stub 
> '(run [this ^String text] 
>     (let [ann (edu.stanford.nlp.pipeline.Annotation. text)] 
>       (.annotate this ann) ann))) 
>
>
> (extend-protocol IComponent 
> edu.stanford.nlp.pipeline.POSTaggerAnnotator      co-stub 
> edu.stanford.nlp.pipeline.PTBTokenizerAnnotator   co-stub 
> edu.stanford.nlp.pipeline.WordsToSentencesAnnotator co-stub 
> edu.stanford.nlp.pipeline.CleanXmlAnnotator       co-stub 
> edu.stanford.nlp.pipeline.MorphaAnnotator         co-stub 
> edu.stanford.nlp.pipeline.NERCombinerAnnotator    co-stub 
> edu.stanford.nlp.pipeline.RegexNERAnnotator       co-stub 
> edu.stanford.nlp.pipeline.TrueCaseAnnotator       co-stub 
> edu.stanford.nlp.pipeline.ParserAnnotator         co-stub 
> edu.stanford.nlp.pipeline.DeterministicCorefAnnotator co-stub 
> ) 
>
> neither quoted version nor the back-quoted version work...The former 
> throws : 
> ClassCastException clojure.lang.PersistentList cannot be cast to 
> java.lang.Class  clojure.core/implements? (core_deftype.clj:512) 
>
> seems to me that extend-protocol expects a class there or a list
 

> and the latter throws: 
>
> ClassCastException clojure.lang.Cons cannot be cast to java.lang.Class   
> clojure.core/implements? (core_deftype.clj:512) 
>
> any macro-gurus around? 
>
> Jim 
>

-- 
-- 
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.


Reply via email to