SE-0397 (second review): Freestanding declaration macros

Hello, Swift community.

The first review of SE-0397 ran from April 27th through May 8th. Feedback was light but positive.

There was an interesting question raised during the review about how these freestanding declaration macros interact with non-freestanding macros applied to it. The immediate answer to this is straightforward: the reviewed version of SE-0397 does not allow attributes or modifiers to be applied to the freestanding macro site, and so direct interaction is impossible. However, it is reasonable to ask how this should interact, and the author has revised the proposal to try to answer this.

The Language Workgroup is otherwise satisfied with this proposal. Accordingly, SE-0397 is accepted in principle on all other aspects, and its review is extended until May 22nd, 2023, for the narrow purpose of reviewing the additional proposed support for putting modifiers and attributes on freestanding macros.

Reviews are an important part of the Swift evolution process. All review feedback should be either on this forum thread or, if you would like to keep your feedback private, directly to me as the review manager via the forum messaging feature or email. When contacting the review manager directly, please put "SE-0397" in the subject line.

What goes into a review?

The goal of the review process is to improve the proposal under review through constructive criticism and, eventually, determine the direction of Swift. When writing your review, here are some questions you might want to answer in your review:

  • What is your evaluation of the proposal?
  • Is the problem being addressed significant enough to warrant a change to Swift?
  • Does this proposal fit well with the feel and direction of Swift?
  • If you have used other languages or libraries with a similar feature, how do you feel that this proposal compares to those?
  • How much effort did you put into your review? A glance, a quick reading, or an in-depth study?

More information about the Swift evolution process is available at

Thank you for your contribution to Swift.

John McCall
Review Manager


Technically, the new rule regarding attributes and modifiers contradicts the outside-in rule of the other macro proposals. However, I think the proposed rule is the right choice. It will be the more useful in practice compared to a rule that sticks to the outside-in expansion model.

Is there a main toolchain that is known good with the macro example's repo? The latest toolchain just crashes on build.

The May 9 toolchain is building successfully for me.

I justified this to myself based on the grammar. Given the example

@available(toasterOS 2.0, *)
public #gyb(...)

The grammar says that this is a freestanding macro declaration, and the attribute is inside that freestanding macro declaration, so it's still "outside-in".



The revised behaviour to apply modifiers to the declaration produced by the macro is reasonable and expected. I'm excited to take this for a spin.

SE-0397 has been accepted; thank you, all, for your participation in this review.

John McCall
Review Manager