java - How to call a gen-class method from clojure -
java - How to call a gen-class method from clojure -
i'm using gen-class generate java-classes clojure code. in order create gen-class work, need add together additional first parameter methods added class (here called this).
(ns com.stackoverflow.clojure.testgenclass (:gen-class :name com.stackoverflow.clojure.testgenclass :implements [com.stackoverflow.clojure.testgenclassinterface] :prefix "java-")) (def ^:private pre "start: ") (defn java-addtostring [this text post] (str pre text post)) after compilation, calling method in java-context works fine.
(def var (com.stackoverflow.clojure.testgenclass.)) (.addtostring var "aus clojure heraus (methode 1)." " :ende") (. var addtostring "aus clojure heraus (methode 2)." " :ende") but how can start straight clojure?
thge next not work, since first parameter missing.
(java-addtostring "text" " :end") is practice phone call function empty first parameter?
(java-addtostring "" "text" " :end") or should add together function (e.g. addtostring) utilize internally , phone call function 1 added method class-file?
to want treat same code method on generated class , function separate said class seems bit smelly me (in sense of code smell, indicates problem somewhere in design).
perhaps addtostring should static method?
perhaps should create add-to-string function can used straight in clojure, , called addtostring method?
we'd need know more larger design before know best answer, suspect 1 of those.
java clojure compilation call gen-class
Comments
Post a Comment