Skip to content

Commit fe4d483

Browse files
authored
[SE-0285] Amend API design guidelines (#1163)
Modifies proposal to include a new API design guideline describing when `#fileID`, `#filePath`, or `#file` should be used.
1 parent 9610c2d commit fe4d483

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

proposals/0285-ease-pound-file-transition.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,18 @@ Additionally, Swift 5 mode and earlier will not warn when:
133133

134134
In Swift 5 mode, substituting `#file` for `#fileID` *will* actually result in different behavior, so ideally we would warn about this. However, doing that would cause new warnings in existing functions which wrap functions that adopt `#fileID`. In practice, most `#fileID` adopters will work fine when they're passed `#file`—they'll just generate unnecessarily large file strings.
135135

136+
### Swift API Design Guidelines amendment
137+
138+
This guideline will be added to [the "Parameters" section][api-params] of the Swift API Design Guidelines:
139+
140+
> * **If your API will run in production, prefer `#fileID`** over alternatives.
141+
> `#fileID` saves space and protects developers’ privacy. Use `#filePath` in
142+
> APIs that are never run by end users (such as test helpers and scripts) if
143+
> the full path will simplify development workflows or be used for file I/O.
144+
> Use `#file` to preserve source compatibility with Swift 5.2 or earlier.
145+
146+
[api-params]: https://swift.org/documentation/api-design-guidelines/#parameter-names
147+
136148
### Schedule
137149

138150
Ideally, these changes will be included in Swift 5.3, with the "future language mode" parts tied to a frontend flag for testing, rather than a language version mode.

0 commit comments

Comments
 (0)