This is the mail archive of the kawa@sourceware.cygnus.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]

still having troubles migrating from 1.6.1... confusing behavior,docs


I'm still having trouble migrating from Kawa 1.6.1. That is the last version
that seems to work reliably to do what we want to do.

We want to set up an environment in a running Java program and evaluate a
whole series of expressions.

Under 1.6.1 this works:

    private Scheme myInterpreter;
    private Environment myEnvironment;
    myInterpreter = new Scheme();
    myEnvironment = myInterpreter . getEnvironment ();
    Environment . setCurrent ( myEnvironment );


and then use eval statements to our heart's content using the eval method on
Scheme:

        myInterpreter . eval (
            "(define (member? str lis) "+
                "(if (member str lis) #t #f))" );

And this works great.

Under 1.6.xx (higher than 1.6.1) this technique blows up with an exception
(and no detail message in the exception). We're using the prebuilt library
so it is a bit hard to trace.

I then tried this, based on the suggestion in the online documentation:

    Environment . setCurrent ( new Scheme () . getEnvironment () );

The docs say "before you start, you need to initialize the global
environment, which you can with (the above)." This blows up with an
exception again with no detail message.

I then tried the alternative method mentioned in the documentation:

    Scheme scm = new Scheme ();
    Object res = scm . eval (
        "(define (exclude lis exc) "+
            "(if (null? lis) '() "+
                "(if (not (member (car lis) exc)) "+
                    "(cons (car lis) (exclude (cdr lis) exc)) "+
                        "(exclude (cdr lis) exc))))" );

This blows up in the eval, probably because there is no valid environment
and all the symbol lookups fail.

How are people doing this? There must be a simple way to setup an
interpreter, setup the environment, and then keep it around and evaluate
statements on it. Trying to figure it out from the read-eval-print sample is
hard because it uses very different methods to access the interpreter. The
docs really need to be fixed to show a simple way to do this.

Thanks for any explanation.

Paul


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