MacroResultand instead allow macros to emit diagnostics via the macro expansion context.
sourceLocationConverterfrom the macro expansion context; it provides access to the whole source file, which interferes with incremental builds.
expansion(of:in)to make it clear that it's producing the expansion of a syntax node within a given context.
- Remove the implementations of
#column, as well as the implication that things like
#linecan be implemented with macros. Based on the above changes, they cannot.
- Introduce a new section providing declarations of macros for the various
#expressions that exist in the language, but will be replaced with (built-in) macros.
- Replace the
external-macro-nameproduction for defining macros with the more-general
macro-expansion-expression, and a builtin macro
externalMacrothat makes it far more explicit that we're dealing with external types that are looked up by name. This also provides additional capabilities for defining macros in terms of other macros.
- Add much more detail about how macro expansion works in practice.
- Introduce SwiftPM manifest extensions to define macro plugins.
- Added some future directions and alternatives considered.
The prototype implementation is also making good progress: it's integrated in the compiler behind some experimental feature flags and is able handle some interesting macros. I'll follow up with some instructions on writing your own macros to try it out.
I'd love to hear your thoughts on this new revision!