This is the mail archive of the
kawa@sources.redhat.com
mailing list for the Kawa project.
Re: Unbound scheme procedures when calling from Java
- From: Per Bothner <per at bothner dot com>
- To: Chris Dean <Chris dot Dean at sokitomi dot com>
- Cc: Vladimir Tsichevski <wowa at jet dot msk dot su>, Esko Nuutila <enu at peak1 dot cs dot hut dot fi>, kawa at sources dot redhat dot com, esko dot nuutila at hut dot fi
- Date: Tue, 01 Apr 2003 08:29:53 -0800
- Subject: Re: Unbound scheme procedures when calling from Java
- References: <200303311237.h2VCbX99005515@peak1.cs.hut.fi> <3E886104.3030900@jet.msk.su> <11576.1049137936@mercedsystems.com>
Chris Dean wrote:
We are trying to call our own Scheme procedures from Java.
Another way to do it is to get a ModuleMethod and call that from Java.
This will work no matter what the setting of module-static:
ModuleMethod test = (ModuleMethod) env.get( "test", null );
System.err.println( "test = " + test );
System.err.println( "result = " + test.apply0() );
Slightly better/cleaner might be to use Procedure:
Procedure test = (Procedure) env.get( "test", null );
test.apply0();
Though I think it unlikely that user-defined functions
will no longer be ModuleMethod, it is even less likely
that they will cease being Procecedures. In any case,
using Procedure also works for builtin or halt-written
procedures.
You might also consider using 'eval' instead of 'get':
Scheme scm = Scheme.getInstance();
// or scm = new Scheme();
Procedure test = (Procedure) scm.eval("test");
This is slower than using get (though it doesn't matter
unless its in an inner loop), but you don't have to
explicitly work with environments.
--
--Per Bothner
per at bothner dot com http://per.bothner.com/