[Pitch] Declaration macros

This looks quite awesome, being able to generate code like this opens so many possibilities.

One thing I'm not clear is in the "order of execution" inside the compiler. macros seem to run after type checking, but that means that if a macro wants to add the implementation for the requirements of a protocol, the compiler needs to type check the conforming type after macro expansion. Is that how it works or does this use case not work? or maybe this is where declaring the names before hand comes into play too?

Also seeing how the peers parameter is separated from .attached in @declaration, does that mean it can be used with .freestanding too? I guess the compiler will give an error message if one tries to use it with freestanding? I know this is not really "swift code" but it feels a bit weird, if this was Swift I would expect the peers to be an associated value of .attached.

@declaration(.freestanding)
@declaration(.attached(peers: [.overloaded]))

exciting pitch!

1 Like