Does all clojure code work in a Java proxy?

I was wondering if there is any clojure code or macros that doesn't work when embedding in a proxy server for clojure for Java code, for example:

(proxy [Some Java Interface] []
  (some Java Method [args]
  ...
  Clojure code
  ...
  )
)

Or can I only embed calls in Java functions in a proxy?

+5
source share
1 answer

Any Clojure code should work inside proxy.

Behind the scenes, Clojure functions are compiled into Java objects anyway, and calling the Clojure function is technically a Java method call. Macro extension still works normally with proxy. Reader macros work fine, etc.

user> (defmacro foo [] "FOO")
#'user/foo

user> (.toString (proxy [Object] [] 
                   (toString [] 
                     (str (foo) \space (reduce + (range 5))))))
"FOO 10"
+6
source

All Articles