I found sample code for a Scala runtime script in response to Generating a class from a string and creating it in Scala 2.10 , however the code seems deprecated for 2.11 - I cannot find any function that matches build.setTypeSignature . Even if it worked, the code seems hard to read and follow me.
How to compile and execute Scala scripts in Scala 2.11?
Suppose I want the following:
- define several variables (names and values)
- compile script
- (optional improvement) values โโof change variables
- execute script
For simplicity, consider the following example:
I want to define the following variables (programmatically, from code, not from script text):
val a = 1 val s = "String"
I want the following script to be compiled and, after execution, return String from it the value "a is 1, s is String" :
s"a is $a, s is $s"
What should my functions look like?
def setupVariables() = ??? def compile() = ??? def changeVariables() = ??? def execute() : String = ???
reflection scripting scala compilation
Suma Mar 31 '15 at 16:23 2015-03-31 16:23
source share