Well, this is certainly a possibility. Especially if I do it at
compilation time, I can put the match functions for each class into an
array, and then combine them by climbing the class hierarchies.

Phil


"Jim - FooBar();" <jimpil1...@gmail.com> writes:
> On 02/08/13 12:46, Jim - FooBar(); wrote:
>> or programmatically emit identical extension points for all
>> subinterfaces/subclasses
> (def ^:private co-stub
> '(run [this text]
>   (if (instance? edu.stanford.nlp.pipeline.Annotation text)
>       (do (.annotate this text) text)
>    (let [ann (edu.stanford.nlp.pipeline.Annotation. ^String text)]
>      (.annotate this ann) ann))))
>
> (defn- emit-IComponent-impls* [syms]
>   (mapcat
>     (fn [s]
>       [(symbol (str "edu.stanford.nlp.pipeline." s)) co-stub])
>     syms))
>
> (defmacro ^:private emit-IComponent-impls [& syms]
>   `(extend-protocol IComponent
>      ~@(emit-IComponent-impls* syms)))
>
> and finally you call it like this:
>
> (emit-IComponent-impls ;nice trick to avoid enumerating all the identical
> implementations
>   POSTaggerAnnotator PTBTokenizerAnnotator WordsToSentencesAnnotator
> TokenizerAnnotator
>   CleanXmlAnnotator MorphaAnnotator NERCombinerAnnotator RegexNERAnnotator
>   TrueCaseAnnotator ParserAnnotator DeterministicCorefAnnotator)
>
> neat trick imo :)
>
> Jim
>
> -- 

-- 
Phillip Lord,                           Phone: +44 (0) 191 222 7827
Lecturer in Bioinformatics,             Email: phillip.l...@newcastle.ac.uk
School of Computing Science,            
http://homepages.cs.ncl.ac.uk/phillip.lord
Room 914 Claremont Tower,               skype: russet_apples
Newcastle University,                   twitter: phillord
NE1 7RU                                 

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