This is the mail archive of the kawa@sources.redhat.com mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Using 'eval' wrongly?


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 




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]