java - "eval" in Scala -
Can Java applications be used in scripts?
I need to load a piece of skala code from Java, setting it to an executable scope (highlighted data by the host application), evaluate it and retrieve the resulting object.
The Scala document shows how easy it is to call the compiled scala code from Java (since it has changed to a regular JVM videocode).
But how do I evaluate the Scala Expression fly (from Java or if it's easy, from within Scala)?
For many other languages, javax.scripting is the interface. Scala does not support it, and I can not find anything in the Java / Scala Interoperability DOC, which does not rely on forward-time compilation.
Scala is not scripting language; it can see some like a scripting language , And people can advocate for that purpose, but it is not exactly right within the JSR 223 scripting framework (which is oriented towards dynamically typed languages). To answer your basic question, there is no eval
function in Scala like Java does not have eval
My suggestion: your code again Think so you do not need eval
. (Not only hard, even in languages, like Ruby) Alternatively, you probably do not want to use Scala for this part of your application. If you really need eval
, then try using JRuby, Zarubi, Scala and Java Mesh are very well received. This is part of your system in Java, is part of Scala and another part in the Ruby (bit which requires eval
).
Comments
Post a Comment