Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/scala/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Scala 具体化函数实现而不是引用_Scala_Reflection_Macros_Scala 2.10 - Fatal编程技术网

Scala 具体化函数实现而不是引用

Scala 具体化函数实现而不是引用,scala,reflection,macros,scala-2.10,Scala,Reflection,Macros,Scala 2.10,我需要得到lambda函数实现的AST。我被卡住了,因为具体化是针对论点的,而不是它的价值 val x = (a: Int) => println("a") val t = showRaw(reify(thevalueof x)) //something here should change println(t) 应打印: Expr(Function(List(ValDef(Modifiers(PARAM), newTermName("a"), Ident(scala.Int), Emp

我需要得到lambda函数实现的AST。我被卡住了,因为具体化是针对论点的,而不是它的价值

val x = (a: Int) => println("a")
val t = showRaw(reify(thevalueof x)) //something here should change
println(t)
应打印:

Expr(Function(List(ValDef(Modifiers(PARAM), newTermName("a"), Ident(scala.Int), EmptyTree)), Apply(Select(Select(This(newTypeName("scala")), newTermName("Predef")), newTermName("println")), List(Literal(Constant("a"))))))

我想应该有一个关于splice之类的技巧,但我就是无法做到这一点。

目前没有可靠的方法在宏应用程序之外获取程序的AST(而reify是一个宏,因此它遵守相同的规则)。但是,我们正在试验下一代宏引擎,可能会解决此问题: