Hi.

I have a java interface.
Something like this this.
public interface ITest {
    void printHello();
    void printName(String name);
}

And i get an implementation using reify.

(def impl (reify macrotest.ITest
  (^void printHello [this]
    (println "Hello world!"))
  (^void printName [this ^String name]
    (println (str "Hello, " name))))
)

Also a have a validation method:
(defn validate-state [] (println "Some validation code here"))

So to add it into implementation i have to add int into every method 
manually 

(def impl (reify ITest
  (^void printHello [this]
    *(validate-state)*
    (println "Hello world!"))
  (^void printName [this ^String name]
   * (validate-state)*
    (println (str "Hello, " name))))
)

Is it possible to make a macros that would get the validation method and 
insert this *(validate-state) *into the begining of each method in reify 
automatically.

Something like that?

(def impl (reify-with-validation *validate-state* ITest
  (^void printHello [this]
    (println "Hello world!"))
  (^void printName [this ^String name]
    (println (str "Hello, " name))))
)

Any thoughts on how to do this?

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

Reply via email to