The name argument is a string specifying a Lisp symbol. The name is parsed by a simple parser as described for com.lispworks.LispCalls.checkLispSymbol (with fboundp =
If the symbol is found, it is applied to the arguments args. For each argument, if it is a primitive type or of a class corresponding to a primitive type or a string, it is converted to the corresponding Lisp value. Otherwise it is passed as a jobject. See Types and conversion between Lisp and Java. The result of the call is converted to the return type of the method and returned from the method. The conversion of the result type allows any float to be returned as a double, but does not coerce between integers and floats. For the
Object return value, the result must be either a Java object (jobject or an instance of standard-java-object), or a Lisp object that can be converted to a Java object. See Types and conversion between Lisp and Java.
The Lisp function is an ordinary Lisp function, but it needs to return the right value. Unless the call is using the
Void callers (com.lispworks.LispCalls.callVoidA or com.lispworks.LispCalls.callVoidV), returning the wrong value will call the java-to-lisp-debugger-hook (see init-java-interface) with an appropriate condition, and then return zero of the correct type (that is 0, 0d0 or Java
null) from the call.
The call to the Lisp function is wrapped such that trying to throw out of it does not actually finish the throw, and instead returns zero of the correct type from the call. It is also wrapped by a debugger hook, which is invoked if the code tries to enter the debugger (normally as a result of an unhandled error, but could be any call to
cl:invoke-debugger). The hook calls the java-to-lisp-debugger-hook (see init-java-interface) with the condition, and then calls
cl:abort. If there is no
cl:abort restart inside the Lisp function that catches this abort, this causes returning a zero of the correct type.
An important issue to remember is that when delivering with shaking, LispWorks eliminates symbols for which there is no reference. If the only call to a Lisp symbol
foo is from Java, LispWorks will not see the reference and it will eliminate
foo. To guard against this, you can either pass
foo in a list to the deliver keyword
:keep-symbols, or more conveniently, use the function
hcl:deliver-keep-symbols (see the
LispWorks Delivery User Guide
), for example:
LispWorks User Guide and Reference Manual - 20 Sep 2017