No-expansion attached macro

This is something I did come up with! The following paragraph is extracted from something I wrote (but not publicized) this April for the GSoC proposal SwiftPM support for Swift scripts:

With the new SwiftSyntax and macro system, I feel like the preferable option is to introduce a new kind of macro that provides additional information for tooling without modifying the AST. We only define the macro interface and different build systems can provide different implementations for it. While this might be a viable solution, the new macro kind itself is a pretty big proposal that, with 99% probability, cannot land during the GSoC cycle.

To expand on the idea, I think users can be provided with a metadata macro API package (which only contains the interface), with which they can apply metadata macros to their codes. External tools like build system and IDE then invokes the Swift compiler with the real implementation to extract the metadata in a batch. In this way, external tools can provide metadata functionality while preserving user code compatibility without them.

1 Like