In the last few days I’ve managed to get a version of Scheme/Java interoperability working where Scheme code can call to Java using a side channel alongside the normal communication with the host Wombat process.
Essentially, the calling from Scheme to Java uses this macro:
(library (wombat java) (export call-to-java) (import (chezscheme)) (define-syntax call-to-java (syntax-rules () [(_ n a* ...) (let () (printf "|!~s~a|!" 'n (apply string-append (map (lambda (a) (format " ~a" a)) (list a* ...)))) (let ([result (read)]) (if (and (not (null? result)) (eq? (car result) 'exception)) (apply error (cdr result)) result)))])))
Then, to call the function
fact(5) in Java (if it’s been defined), you would just need to do this:
(call-to-java fact 5)
Then the Java end of things will take over, eventually sending back
(120) (the interop code always returns a list).
Using this, I’ve managed to implement
draw-image with the same Image API.
If you want to switch over to the new versions of Wombat, you can get it here. You should have at least version 2.54.6.