[Accepted] SE-0274: Concise Magic File Names

The second review of SE-0274 has concluded and the proposal has been accepted.

  • #file will be altered to only report the module and filename
  • #filePath will be introduced to replicate the previous full file+path for use cases that relied on the path previously.
  • While the team acknowledges that this does require some existing workflows to adapt to the new scheme, the binary size and privacy concerns over implicitly embedding the full path were significant enough to warrant this change.

During the second review, the format of the new #file value was discussed and will be locked down in a way that users can rely on. The core team expects future tooling to be created that will allow for easy processing of this value.

Some reviewers suggested that the provision of further magic variables for the module and file name would unlock further optimization of binary size. The core team believes this would need more investigation in order to determine whether this is true, due to the trade-offs between increasing the arguments passed versus deduplication of file strings. This may also vary by user practice. As such, this would need to be proposed at a later date with supporting data.

Thanks to everyone for participating in this review.

23 Likes

Thanks @Ben_Cohen, is it clear already what the first Swift version to use this breaking change will be? I think it'd be beneficial to communicate this ASAP so people can start putting #if compiler(>=X.Y) in their codebases if they rely on getting full paths. Especially in test suites I would expect folks to rely on this.

The version after Swift 5.2 (5.3?) will at least include #filePath (as in, I merged it yesterday and it seems unlikely to need a revert). I expect it to also change #file without a feature flag, but that hasn’t been merged yet.

2 Likes

As long as source compatibility is being broken, could we squeeze SE-0155 in as well? Update on SE-0110 and SE-0155

It isn’t—this is a behavior change, not a source break. (The proposal discusses this point.)

That would have to be a separate proposal. The fact that we have decided that one specific, small change is worth the break does not mean it‘s open season for unrelated changes with different scopes and tradeoffs.

1 Like