4 ms·
Some Java: public class Main { public int addTwoNumbers(int a, int b) { return a + b; } } Calling it from ABCL: (defun void-funct
by lvh 10y ago
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 t "in void-function, result of calling addTwoNumbers(2, 4): ~a~%" result)))
Calling it from Clojure:
(defn f []
(prn "calling addTwoNumbers from f" (.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.
Also, my concrete claim was that I could use AWS easily. I can use both the SDK directly quite painlessly (see above) or use https://github.com/mcohen01/amazonica https://github.com/mcohen01/amazonica. Where is the equivalent CL library?
- junke 10y agoUse JSS (http://abcl.org/svn/tags/1.3.0/contrib/jss/README.markdown http://abcl.org/svn/tags/1.3.0/contrib/jss/README.markdown): ;; During initialization (require 'abcl-contrib) (require 'jss) Then, for example: CL-USER(1): (in-package :jss) JSS(2): (lambda (x y) (format t "~&addTwoNumbers(~A, ~A): ~A~%" x y (#"addTwoNumbers" (new 'Main) x y))) #<FUNCTION (LAMBDA (X Y)) {7EEE31B2}> JSS(3): (funcall * 20 30) addTwoNumbers(20, 30): 50 NIL The same goes for any Java library. As for AWS, I have no experience with it. Looking around, there seems to be https://github.com/hargettp/hh-aws https://github.com/hargettp/hh-aws. Btw, I am not attacking Clojure, but the idea that Clojure is the only useful Lisp available on the JVM.
- lvh 10y agoThat is a lot better, thanks. hh-aws is unmaintained and only supports a tiny, tiny fraction of AWS.