Hi Eugene,
Thanks for your immediate and kind response.
I've tested the macro-expand-to-macro thing, it worked, using 3 compilation passes, macro def 1, macro def 2 (who calls def 1) and macro usage (who uses def 2).
But it seems no way to expand to reify and get reify to be expanded again to an another AST.
For example, when I do this,
object P2Macro {
def p2macro(format: String) = macro impl
def impl(c: Context)(format: c.Expr[String]): c.Expr[Any] = {
c.universe.reify { c.universe.reify { 100 } }
}
}
I will end up with:
scala> P2Macro.p2macro("100")
<console>:8: error: Macro expansion contains free term variable c defined by impl in P2Macro.scala:7:12. Have you forgotten to use splice when splicing this variable into a reifee? If you have troubles tracking free term variables, consider using -Xlog-free-terms
P2Macro.p2macro("100")
I assume this is because the reify implementation will look for ASTs in its body and try to splice it. But how am I suppose to achieve this?
Using quasiquotes with fully-resolved symbols is either no luck, but maybe I'm doing it wrong.
For example,
val m1 = symbolOf[c.universe.type].asClass
val r1 = m1.info.member(TermName("reify"))
c.Expr(q"$r1(100)")
Is this because the reify method is a macro method builtin into the complier and it's impossible to nest it in macro expansion?
Also, about Project Palladium, I've read the slides on NE Scala, really cool stuff! Makes macro much more usable. Looking forward to your future updates.