this post was submitted on 20 Oct 2023
1 points (100.0% liked)
Lisp
53 readers
3 users here now
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
(defn foo [^^GoogleFactoryProxy factory-proxy] (doto (.fooMethod factory-proxy) (.addStuff (stuff))))
doto is great for functions returning void. You can still use threading macro if the Java object returns self.
Method hints pop up after the first dot.
If you need to implement interfaces or extend objects then I would write wrappers which do the reify work and pass function arguments to those wrappers. Otherwise the code becomes noisy and has less signal.
Honestly, I have found that extending objects is just easier in Java. The clojure interface for that is generally not worth the effort.