I was wondering if there is any clojure code or macros that does not work when embedded within a clojure proxy for java code, eg:
(proxy [Some Java Interface] []
(some Java Method [args]
...
Clojure code
...
)
)
Or, can I only embed calls to Java 开发者_如何学Pythonfunctions within the proxy?
Any Clojure code should work inside proxy
.
Behind the scenes, Clojure functions are compiled into Java objects anyways, and calling a Clojure function is technically a Java method call itself. Macro expansion still works normally with proxy
. Reader macros all work normally etc.
user> (defmacro foo [] "FOO")
#'user/foo
user> (.toString (proxy [Object] []
(toString []
(str (foo) \space (reduce + (range 5))))))
"FOO 10"
精彩评论