4 ms·
ABCL exists and is easier to use java libs from than Clojure
by zelcon 7y ago
ABCL exists and is easier to use java libs from than Clojure
- bitwize 7y agoSo does/is Kawa.
- dkersten 7y agoBut does it have the things that make me use Clojure? (Immutable default data structures, sequence abstraction, general philosophy behind things eg data > functions > macros)
- lvh 7y agoIt 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.