I'm a big fan of this concept, but I want to reiterate my feedback from the pitch:
I would be strongly in favour of this proposal if preamble macros were replaced with wrapper macros, given that the latter are a strict superset of the former (unless I'm missing something?) To reiterate, AFAICT if a macro author wishes to write a preamble-style macro they can create a wrapper macro that returns something like
{ preamble; return h-impl }()
I think there's a lot of patterns that fit the wrapper form but not the preamble form. For example, there's currently an open PR on the Swift repo to implement support for the preamble form in task locals:
Seems to me that Wrapper macros would preclude the need for new APIs like this, offer a safer interface, and work in far more situations. Reiterating my feedback from the pitch again, this also makes it a far simpler decision when choosing which style of function body macro you want:
- wrapper: can compose, can't rewrite the body. improved local reasoning.
- body: can't compose, but can fully rewrite the body. reduced local reasoning.