[armedbear-devel] Several ABCL/Java questions
didier at lrde.epita.fr
Tue Jan 4 15:55:52 UTC 2011
Alessio Stalla <alessiostalla at gmail.com> wrote:
> You do need one. You can either use ABCL's one - in that case you have
> to pass something like --eval "(your-main-function)", perhaps with a
> shell script - or write a custom one in Java that will call the right
> Lisp function.
Here's the closest thing I have to "standalone" ABCL executables so far.
Comments welcome (remember: I don't know Java).
| import org.armedbear.lisp.*;
| public class Main
| public static void main (String argv)
| LispObject cmdline = Lisp.NIL;
| for (String arg : argv)
| cmdline = new Cons (arg, cmdline);
| cmdline.nreverse ();
| Lisp._COMMAND_LINE_ARGUMENT_LIST_.setSymbolValue (cmdline);
| Interpreter interpreter = Interpreter.createInstance ();
| // load a lisp file like main.lisp or so.
| catch (Throwable t)
| t.printStackTrace ();
javac -cp /usr/local/pkg/common-lisp/abcl/\* Main.java
java -cp /usr/local/pkg/common-lisp/abcl/\*:. Main [options...]
And now from that interpreter (in fact, its #'main function),
*command-line-argument-list* contains the list of [options...], with the
notable effect that none of them are processed by, or affect ABCL
- I can also provide my own jar file, only it seems painful to do
because I would have to uncompress abcl.jar to get all its contents
and then create my own by adding Main.class to it. I've seen threads
dating back to 2007 about adding jar files to jar files directly but
it seems that it still doesn't work the way I want it to (accessing
the sub-jar's contents). Correct?
- A cleaner way to do the above would have been to extend the
Interpreter class by adding a new method, e.g. createStandaloneInstance,
as a mixture of createDefaultInstance and createInstance. Unfortunately,
this is not possible because this class is final.
Resistance is futile. You will be jazzimilated.
Scientific site: http://www.lrde.epita.fr/~didier
Music (Jazz) site: http://www.didierverna.com
More information about the armedbear-devel