Using Scheme from Java is straight forward, though the API has been evolving. You can use the class silk.Scheme to provide a read-eval-print loop which is good for development. However, in your real applcation you might like to hid the fact that you are using Scheme. This can be done by:
For example, you can define an action listener that will invoke a Scheme procedure:
public class SchemeActionListener extends silk.SchemeUtils
implements java.awt.event.ActionListener {
Procedure p;
SchemeActionListener(Procedure p) { this.p = p; }
public void actionPerformed(java.awt.event.Actionevent e) {
Scheme.apply(p, cons(e, null)); }
}
You can then invoke it from Scheme using.
(import "SchemeActionListener") (import "javax.swing.JButton") (define button (Jbutton "press me")) (add button (SchemeActionListener (lambda (e) (display e))))
From Java, you can also add a known global function, fred, as a call back using:
Scheme.apply(scheme.getGlobal("fred"), args);