This is the mail archive of the
kawa@sources.redhat.com
mailing list for the Kawa project.
Using 'eval' wrongly?
- To: kawa at sourceware dot cygnus dot com
- Subject: Using 'eval' wrongly?
- From: Jocelyn Paine <popx at pop3 dot ifs dot org dot uk>
- Date: Mon, 27 Aug 2001 20:25:31 +0100 (GMT)
I'm testing that I can construct expressions and evaluate them from Java.
There's some code below which I think ought to call eval to evaluate (- 1
2), and return -1. What it actually seems to return is an empty Values,
presumably representing #!void. I know that evaluation is looking for the
binding of the - operator, because if I change it to an unbound symbol,
then eval reports that it is unbound. But what has happened to the result?
Something obviously wrong with my code, e.g. a level of nesting out?
public static void main( String[] argv )
{
Scheme interp = new Scheme();
Environment.setCurrent( interp.getEnvironment() );
Pair call = LList.list3( "-", new gnu.math.IntNum(1), new gnu.math.IntNum(2) );
Object result = interp.eval( call, Environment.current() );
System.out.println( result );
Object[] values = ( (gnu.mapping.Values)result ).getValues();
for ( int i=0; i<values.length; i++ )
System.out.println( values[i] );
}
Jocelyn Paine
http://www.ifs.org.uk/~popx/
+44 (0)7768 534 091