Is there an exit-hook function in abcl?

Vibhu Mohindra vibhu.mohindra at gmail.com
Wed Oct 19 09:12:25 UTC 2016


Java lets you do:

Runtime.getRuntime().addShutdownHook(
  new Thread(){public void run(){/*...*/}});

ABCL lets you call Java and lets Java call your ABCL functions.

If ABCL doesn't already do what you want, something like this will make it:

;in Lisp we want to be able to write
(defun my-hook () nil)
(sys:exit-hook 'my-hook)

//so let's build some support, in java
Runtime r = Runtime.getRuntime();
Lisp.intern("SYS:EXIT-HOOK").setSymbolFunction(
  new Function(){public void execute(LispObject hook){
    r.addShutdownHook(new Thread(){public void run(){
      hook.execute();}});}});

I've probably got some method and package names wrong, but that's the gist.

If you don't want to write the Java section above in Java, you can write
it in Lisp. But I remember even less of the Lisp to Java syntax, so I
won't embarrass myself with any more code.

Vibhu



More information about the armedbear-devel mailing list