New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support syntactic/semantic macros at all locations #536
Comments
Some examples of useful def macros that can be done syntactically
|
I'd strongly advise against supporting semantic APIs for macro annotations. scalamacros/paradise#75 shows that it's too much trouble for too little gain. |
I also have a comment about the proposed notation to distinguish syntactic and semantic meta blocks. Strictly speaking, syntactic meta blocks should also take a capability, namely a dialect. This is currently not reflected in the prototype implementation, but I think that it should work like that for completeness. |
After implementing syntactic def macros in Eden, now I don't think syntatic def macros should have a different syntax from semantic ones. Close this for now. |
Tonight I conducted a conversation with @olafurpg , we agreed that syntactic def macros can also be very useful in practice. At the same time, programmers may want to use semantic APIs for annotation macros.
To support the scenarios above, we can follow the capability metaphor of scala.meta:
The syntactic APIs are imported by default via
import scala.meta._
, while semantic APIs can only be accessed viameta { mirror => }
. This way, we can control whether a macros definition is semantic or syntactic, and expand them accordingly. In Dotty, this syntactical difference also tells macros authors whether the trees are desugared or not.Usage of semantic APIs for annotation macros can be both useful and tricky, programmers use it at their own risk.
The text was updated successfully, but these errors were encountered: