bugKawa - Bugs: bug #48652, Cannot run Scheme.eval multiple...

 
 

bug #48652: Cannot run Scheme.eval multiple times

Submitted by:  Ronald Blaschke <rblasch>
Submitted on:  Thu 28 Jul 2016 08:08:32 PM UTC  
 
Category: Code generationSeverity: 3 - Normal
Item Group: Run-time exceptionStatus: Fixed
Privacy: PublicAssigned to: Per Bothner <bothner>
Open/Closed: Closed

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Fri 29 Jul 2016 10:03:28 AM UTC, comment #2:

Wow, that was fast. The fix works nicely, thank you very much!

Ronald Blaschke <rblasch>
Thu 28 Jul 2016 11:24:23 PM UTC, comment #1:

There is actually code to deal with this, by call the setEvalName method in Language.eval. Unfortunately, setEvalName is called too late ...

I checked in a fix.

Per Bothner <bothner>
Project AdministratorIn charge of this item.
Thu 28 Jul 2016 08:08:32 PM UTC, original submission:

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.

Ronald Blaschke <rblasch>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by bothner (Posted a comment)
  • -unavailable- added by rblasch (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sat 30 Jul 2016 05:24:50 AM UTCbothnerOpen/ClosedOpen=>Closed
    Thu 28 Jul 2016 11:24:23 PM UTCbothnerStatusNone=>Fixed
      Assigned toNone=>bothner

    Back to the top


    Powered by Savane 3.1-cleanup1