Re:Cloture: Clojure in Common Lisp
by zelcon on Thursday February 13, 2020 @11:28PM
(#22323960)
ABCL exists and is easier to use java libs from than Clojure
[ Parent
| on HN ]
But does it have the things that make me use Clojure? (Immutable default data structures, sequence abstraction, general philosophy behind things eg data > functions > macros)
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.
Re:Cloture: Clojure in Common Lisp
by fmakunbound on Friday February 14, 2020 @01:02PM
(#22328609)
Something like:
(require :jss)
(defun f()
(format t "calling addTwoNumbers(2, 4): ~A" (#"addTwoNumbers" 'Main 2 4))Thanks! I didn't know about :jss and will happily concede that's equivalent to the Clojure version.