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 functions 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"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With