In light of the discussion of principles for (trailing closure) evolution proposals and based on feedback we've received from the Swift 5.3 development snapshots, I'd like to revisit SE-0274: Concise magic file names. In particular, I feel like SE-0247 has violated the "Source Compatibility" principle more than is necessary, and that we should consider revising the proposal.
SE-0247 includes an additive change (
#filePath literal to provide the full path to the file), but then introduces three changes that affect existing sources:
#fileliterals have a different form that does not include the full path name. Therefore, the spelling
#filehas changed meaning.
- The compiler provides a warning when a wrapper around a
#filePath-defaulting function passes it
#fileinstead, or vice versa.
- Standard library functions like
#file, and therefore have had their behavior changed to no longer produce the full path name by default.
My concern is with #1 and #2. With #1, we have changed language semantics without a language version bump and without a deprecation cycle. With #2, we are seeing a bunch of warnings in user code about the migration. In both cases, if you want to fix your code to work with Swift 5.2 and Swift 5.3, you have to use
#if's on language version in a bunch of places, which is an unfortunate workaround because it litters code with unnecessary divergence.
I consider #3 to be a necessary semantic change. As the proposal highlights, the standard library is effectively leaking private information about the build environment into binaries, and paying a significant percentage of the code size to do so.
Here is my proposal for fixing these issues with SE-0247:
#fileIdto have the shortened spelling
- Update all of the Standard Library's usage of
#filemeaning the same thing as
#filePathin Swift 5.3
- Change the meaning of
#fileto be an alias of
#fileIdin Swift 6
(Note: I advocated for SE-0247 as it was accepted, including the source breaks above, but I've been thinking about that decision more in light of the other discussions going on.)