Since untyped macros are out, the number of macro variants that avoid initial type checking has been diminished.
The rationale in the relevant release doc references both implicit macros and macro annotations as alternatives.
And indeed macro annotations do seem to work as advertised. However, I was unable to find an example of an implicit macro (one I understood at least) or another macro variant being deployed in this situation.
So, once again, the question is: apart from macro annotations, what macro creation methods avoid immediate type checking, and how do they differ in this regard?
The specific use case spurring my investigation is transforming something like this (realized with macro annotations):
{
@blah
val x = {
foo("a")
bar()
}
}
Where foo
and bar
are not defined anywhere in the current scope before the macro application. The intended use case is a DSL. The above example is only given for context, so please don't limit your answers to this scenario.
At the moment (Scala 2.11.0-M8, Macro Paradise 2.0.0-M3), macro annotations implemented in macro pardise is the only macro flavor that doesn't typecheck macro arguments prior to expansion.
There is also an experimental dsl-paradise proposal to extend Scala with scope injection that would allow def macros to be not quite typed in a controlled manner, but it's currently in the early implementation phase, so it's not usable just yet.
The future of untyped macros in official Scala is currently unclear. On the one hand, we recognize that untyped macros are at times useful (e.g. for type providers, scope injection), but, on the other hand, it looks like in their most general form, such macros are more powerful than we would like them to be (see my StrangeLoop talk about philosophy of Scala macros starting from 27:40 and a recent discussion at scala-internals). Therefore future experimentation is required to elaborate on the exact shape in which untyped macros should enter trunk.