Details

      Description

      Currently, to use Scala as a scripting engine, one has to do:

      import scala.tools.nsc.*;
      Interpreter n=new Interpreter(new Settings());
      n.bind("label", "Int", new Integer(4));
      n.interpret("println(2+label)");
      // didn't event try to check success or error
      n.close();

      It would be nice if one could do instead:

      import javax.script.*;
      ScriptEngine e = new ScriptEngineManager().getEngineByName("scala");
      e.getContext().setAttribute("label", new Integer(4), ScriptContext.ENGINE_SCOPE);
      try {
          engine.eval("println(2+label)");
      } catch (ScriptException ex) {
          ex.printStackTrace();
      }

      Plus, as was pointed elsewhere, the compiler used in the background by the interpreter should not need a filesystem (for instance if scripting is to be used on handheld devices etc.)

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                rjolly rjolly
                Reporter:
                rjolly rjolly
                TracCC:
                cwhite102, Lucien Pereira, Michael, Michael Greifeneder, Romain Reuillon, Scott Murphy, Seth Tisue
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: