bug-kawa
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-kawa] [bug #48652] Cannot run Scheme.eval multiple times


From: Ronald Blaschke
Subject: [Bug-kawa] [bug #48652] Cannot run Scheme.eval multiple times
Date: Thu, 28 Jul 2016 20:08:34 +0000 (UTC)
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:47.0) Gecko/20100101 Firefox/47.0

URL:
  <http://savannah.gnu.org/bugs/?48652>

                 Summary: Cannot run Scheme.eval multiple times
                 Project: Kawa
            Submitted by: rblasch
            Submitted on: Thu 28 Jul 2016 08:08:32 PM GMT
                Category: Code generation
                Severity: 3 - Normal
              Item Group: Run-time exception
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any

    _______________________________________________________

Details:

Consider the following example:

import kawa.standard.Scheme;

public class Test {
    public static void main(final String[] args) throws Throwable {
        final Scheme scheme = new Scheme();
        scheme.eval("(define a 1)");
        System.out.println(scheme.eval("a"));
    }
}

This fails with the following exception:

Exception in thread "main" java.lang.NoSuchFieldError: a
        at \^string\_.run(<string>:1)
        at gnu.expr.ModuleExp.evalModule2(ModuleExp.java:293)
        at gnu.expr.ModuleExp.evalModule(ModuleExp.java:212)
        at gnu.expr.Language.eval(Language.java:1298)
        at gnu.expr.Language.eval(Language.java:1237)
        at gnu.expr.Language.eval(Language.java:1219)
        at Test.main(Test.java:7)

The problem seems to be that eval first compiles the given String to a class,
which is then executed, but the class name is always "\^string\_".
(Probably derived from the constant "<string>" identifier?)

There are two workarounds that seem to work:

1) Use Scheme#eval(String, Environment), which seems to do things a little
different.

2) Use Scheme#eval(InPort) with a unique Path:

import gnu.kawa.io.InPort;
import gnu.kawa.io.Path;
import kawa.standard.Scheme;

import java.io.StringReader;

public class Test {
    public static void main(final String[] args) throws Throwable {
        final Scheme scheme = new Scheme();
        scheme.eval(
            new InPort(new StringReader("(define a 1)"), Path.valueOf("1"))
        );
        System.out.println(scheme.eval(
            new InPort(new StringReader("a"), Path.valueOf("2"))
        ));
    }
}

Currently, I am considering the second workaround, with the String's SHA-1 as
Path.




    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?48652>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]