3 ms·
It does not seem easier to me to use Java libs from ABCL than Clojure. Some Java: public class Main { public int addTwoNumbers(int a, int b) { ret
by lvh 7y ago
It does not seem easier to me to use Java libs from ABCL than Clojure.
Some Java:
public class Main {
public int addTwoNumbers(int a, int b) {
return a + b;
}
}
Calling it from ABCL:
(defun void-function (param)
(let* ((class (jclass "Main"))
(intclass (jclass "int"))
(method (jmethod class "addTwoNumbers" intclass intclass))
(result (jcall method param 2 4)))
(format "calling addTwoNumbers(2, 4): ~a~%" result)))
Calling it from Clojure:
(defn f []
(prn "calling addTwoNumbers(2, 4): " (.addTwoNumbers (Main.) 2 4)))
Note that the Clojure version creates the object, and the ABCL version doesn't do that for you; you still need to instantiate a Main yourself.
- fmakunbound 7y agoSomething like: (require :jss) (defun f() (format t "calling addTwoNumbers(2, 4): ~A" (#"addTwoNumbers" 'Main 2 4))
- lvh 7y agoThanks! I didn't know about :jss and will happily concede that's equivalent to the Clojure version.