score:0

the comment about scala.tools.reflect.toolbox put me on the right track and i ended up being able to answer my own question. something like this is what i was looking for:

import scala.reflect.runtime._
import scala.reflect.runtime.universe._
import scala.tools.reflect.toolbox

object main extends app {

  val cm = universe.runtimemirror(getclass.getclassloader)
  val toolbox = cm.mktoolbox()

  val f = toolbox.eval(toolbox.parse("""(x:double) => x*x"""))
  f match {
    case f1:scala.function1[double, any] => 
        println(f1(4.4))
    case _ => 
        throw new exception("expected a function1[double,any] but got something else")
  }

}

Related Query

More Query from same tag