如何在Scala中打印展开的宏? [英] How do I print an expanded macro in Scala?
问题描述
我正在Scala中编写宏,但是当我调用它时,我收到一条错误消息,提示"Double not not parameters".显然,宏如何构建AST有点问题.那我怎么看扩展的宏呢?有没有办法在运行时调用宏实现?
I am writing a macro in Scala, but when I call it I get an error message saying "Double does not take parameters". Clearly there is something wrong with how the macro builds the AST. So how can I see the expanded macro? Is there a way to call the macro implementation at runtime?
推荐答案
为编译器提供-Ymacro-debug-lite
或-Ymacro-debug-verbose
选项.
Provide -Ymacro-debug-lite
or -Ymacro-debug-verbose
option to the compiler.
在我的头上,打印的AST的报废行为由-Yshow-trees-compact
,-Yshow-trees-stringified
,-Xprint-types
,-uniqid
和-Yshow-symkinds
控制.您可以通过运行scala -X
和scala -Y
(或在
Off the top of my head, detalization of printed ASTs is governed by -Yshow-trees-compact
, -Yshow-trees-stringified
, -Xprint-types
, -uniqid
and -Yshow-symkinds
. You can find other gems by running scala -X
and scala -Y
(or inspecting the sources of scala settings at https://github.com/scala/scala/blob/2.10.x/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala).
尽管本质上是一个宏,但它却具有自己的跟踪机制,可以由-Yreify-copypaste
和-Yreify-debug
进行配置.
Also, despite being essentially a macro, reification has its own tracing mechanism that can be configured by -Yreify-copypaste
and -Yreify-debug
.
这篇关于如何在Scala中打印展开的宏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!