Syntactic sugar to call Java from ABCL?

Mark Evenson evenson at panix.com
Sat Mar 5 09:02:08 UTC 2016



On 2016/3/4 18:54, EGarrulo wrote:
> Hello ABCL developers,
> 
> has anybody written some macros to make calling Java from ABCL more 
> straightforward?  I mean something that, instead of this code from the ABCL 
> documentation:
> 
> 
> (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)))
> 
> 
> would let you write something like this, for example:
> 
> 
> (format t
>         "in void-function, result of calling addTwoNumbers(2, 4): ~a~%"
>         ;; Let's imagine that we have defined a -> macro.
>         (-> |Main.addTwoNumbers| 2 4)


abcl-1.3.3 currently includes code in the ABCL-CONTRIB mechanism for two
such additional syntaxes, namely [JFLI-ABCL][1] and [JSS][2].

[1]: http://abcl.org/trac/browser/trunk/abcl/contrib/jfli/README
[2]: http://abcl.org/trac/browser/trunk/abcl/contrib/jss/README.markdown

One may load these packages by

```lisp
(require :abcl-contrib)
(require :jfli)
```

or

```lisp
(require :abcl-contrib
(require :jss)
```

I don't really know much about JFLI, but use JSS extensively.

The example of
```lisp
(-> |Main.addTwoNumbers| 2 4)
```

would become

```lisp
(#"addTwoNumbers" 'Main 2 4)
```

in JSS.







-- 
"A screaming comes across the sky.  It has happened before, but there
is nothing to compare to it now."



More information about the armedbear-devel mailing list