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

            Hide
            michid4 michid4 added a comment -
            Show
            michid4 michid4 added a comment - Initial progress here: https://issues.apache.org/jira/browse/SLING-1274
            Hide
            sethtisue Seth Tisue added a comment -
            Show
            sethtisue Seth Tisue added a comment - there's this: http://my.opera.com/zilti/blog/use-scala-as-a-jsr-223-scripting-language (though I haven't tried it)
            Hide
            michid4 michid4 added a comment -

            Replying to [comment:18 SethTisue]:
            > there's this: http://my.opera.com/zilti/blog/use-scala-as-a-jsr-223-scripting-language
            > (though I haven't tried it)

            That's the same on I mentioned here: https://lampsvn.epfl.ch/trac/scala/ticket/874#comment:11

            Show
            michid4 michid4 added a comment - Replying to [comment:18 SethTisue] : > there's this: http://my.opera.com/zilti/blog/use-scala-as-a-jsr-223-scripting-language > (though I haven't tried it) That's the same on I mentioned here: https://lampsvn.epfl.ch/trac/scala/ticket/874#comment:11
            Hide
            retronym Jason Zaugg added a comment - - edited

            This is currently out of scope for the Scala team. We don't see much demand for JSR-223; if there was a community library could fill the gap.

            Show
            retronym Jason Zaugg added a comment - - edited This is currently out of scope for the Scala team. We don't see much demand for JSR-223; if there was a community library could fill the gap.
            Show
            moors Adriaan Moors added a comment - https://github.com/scala/scala/pull/2238

              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: