Just wondering if there is a any way to convert/parse a string, containg a Scala function body block, to a Function object.
Asked
Active
Viewed 155 times
3
-
Do you mean runtime, or compiletime? For the first, probably a [`ScriptEngine`](http://docs.oracle.com/javase/7/docs/api/javax/script/ScriptEngine.html) [implementation](http://stackoverflow.com/questions/11209995/jsr-223-scala-script-engine), for the latter, [quasiquotes](http://docs.scala-lang.org/overviews/quasiquotes/intro.html) with macros. – Gábor Bakos May 29 '15 at 19:26
-
I ment runtime, since I want to receive an expression from an input string, and make it an executable function. – Dario May 29 '15 at 19:32
-
Please see the Scala REPL. https://github.com/scala/scala/tree/2.11.x/src/repl/scala/tools/nsc – Soumya Simanta May 29 '15 at 20:03