You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Make swiftLanguageVersions property deprecated not obsoleted
- Deprecate Swift setting added in SE-0435 in favor of renamed setting
- Add Acknowledgments section
- Fix typos
Copy file name to clipboardExpand all lines: proposals/nnnn-formalize-language-mode-terminology.md
+40-19Lines changed: 40 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,7 +22,7 @@ The **Alternatives Considered** section contains a more detailed discussion of t
22
22
Introduce a `-language-mode` option that has the same behavior as the existing `-swift-version` option, while de-emphasizing the `-swift-version` option in help and documentation.
23
23
24
24
#### Naming note
25
-
The proposed compiler option uses the term 'language mode' instead of 'Swift language mode' because the context of the usage strongly implies a Swift language mode. The intent is that the `languageMode()` compiler condition described in **Future directions** would also use that naming convention for the same reason.
25
+
The proposed compiler option uses the term 'language mode' instead of 'Swift language mode' because the context strongly implies a Swift language mode. The intent is that the `languageMode()` compiler condition described in **Future directions** would also use that naming convention for the same reason.
26
26
27
27
### Swift Package Manager
28
28
Introduce four Swift Package Manager API changes limited to manifests \>= 6.0:
@@ -46,10 +46,10 @@ Package(
46
46
47
47
Add a new `init` method to `Package` with the following changes from the current `init` method:
48
48
49
-
- The paramater`swiftLanguageVersions` is renamed to `swiftLanguageModes`
49
+
- The parameter`swiftLanguageVersions` is renamed to `swiftLanguageModes`
50
50
- The parameter type is now an optional array of `SwiftLanguageMode` values instead of `SwiftVersion` values
51
51
52
-
The existing init method will be marked as obsolete and renamed allowing the compiler to provide a fix-it.
52
+
The existing init method will be marked as `obsoleted` and `renamed` allowing the compiler to provide a fix-it.
53
53
54
54
#### 2. Rename `swiftLanguageVersions` property to `swiftLanguageModes`
55
55
Rename the public `Package` property `swiftLanguageVersions` to `swiftLanguageModes`. Add a `swiftLanguageVersions` computed property that accesses `swiftLanguageModes` for backwards compatibility.
@@ -59,7 +59,7 @@ Rename the public `Package` property `swiftLanguageVersions` to `swiftLanguageMo
59
59
Rename the `SwiftVersion` enum to `SwiftLanguageMode`. Add `SwiftVersion` as a type alias for backwards compatibility.
60
60
61
61
62
-
#### 4. Update API accepted in [SE-0435: Swift Language Version Per Target](https://github.com/apple/swift-evolution/blob/main/proposals/0435-swiftpm-per-target-swift-language-version-setting.md):
62
+
#### 4. Add `swiftLanguageMode()` to `SwiftSetting`
63
63
64
64
```swift
65
65
publicstructSwiftSetting {
@@ -72,7 +72,7 @@ public struct SwiftSetting {
72
72
)
73
73
```
74
74
75
-
If both proposals are implemented in the same release, the accepted SE-0435 API would be added with the proposed naming change.
75
+
The changes in [SE-0435: Swift Language Version Per Target](https://github.com/apple/swift-evolution/blob/main/proposals/0435-swiftpm-per-target-swift-language-version-setting.md) have been implemented and released in pre-release versions of Swift 6.0. This proposal will add `swiftLanguageMode()` as a `SwiftSetting` and deprecate the `swiftLanguageVersion()` setting added by SE-0435 with a `renamed` annotation.
76
76
77
77
#### Naming note
78
78
@@ -99,7 +99,7 @@ The `-swift-version` option will continue to work as it currently does, preservi
99
99
100
100
The `-language-mode` option will be presented in the compiler help.
101
101
102
-
The `-swift-version` option will likely be supressed from the top-level help of the compiler. More investigation is needed on the details of this.
102
+
The `-swift-version` option will likely be suppressed from the top-level help of the compiler. More investigation is needed on the details of this.
103
103
104
104
### Swift Package Manager
105
105
Proposed Swift Package Manager API changes are limited to manifests \>=6.0:
@@ -123,7 +123,7 @@ Package(
123
123
```
124
124
125
125
126
-
The existing init method will be marked as obsoleted and renamed, allowing the compiler to provide a fix-it:
126
+
The existing init method will be marked as`obsoleted` and `renamed`, allowing the compiler to provide a fix-it:
@@ -157,29 +157,30 @@ See the **Source compatibiity** section for more details about this change.
157
157
### Rename `swiftLanguageVersions` property to `swiftLanguageModes`
158
158
Rename the `Package` public property `swiftLanguageVersions` to `swiftLanguageModes`. Introduce a computed property named `swiftLanguageModes` that accesses the renamed stored property for backwards compatibility.
159
159
160
-
The computed property will be annotated as obsoleted in Swift 6, renamed to `swiftLanguageModes`.
160
+
The computed property will be annotated as `deprecated` in Swift 6 and `renamed` to `swiftLanguageModes`.
161
161
162
-
For packages with swift tools version less than 6.0, accessing the `swiftLanguageModes` property will continue to work.
163
-
For 6.0 and later, that access will be an error with a fix-it to use the new property name.
162
+
For packages with swift tools version less than 6.0, accessing the `swiftLanguageModes` property will continue to work.
163
+
164
+
For 6.0 and later, that access will be a warning with a fix-it to use the new property name.
public var swiftLanguageVersions: [SwiftVersion]? {
168
169
get { swiftLanguageModes }
169
170
set { swiftLanguageModes = newValue }
170
171
}
171
172
```
172
173
173
-
See the **Source compatibiity** section for more details about this change.
174
+
See the **Source compatibility** section for more details about this change.
174
175
175
176
### Rename `SwiftVersion` enum to `SwiftLanguageMode`
176
177
Rename the existing `SwiftVersion` enum to `SwiftLanguageMode` with `SwiftVersion` added back as a type alias for backwards compatibility.
177
178
178
-
This change will not affect serializaiton of PackageDescription types. Serialization is handled by converting PackageDescription types into separate, corresponding Codable types. The existing serialization types will remain as-is.
179
+
This change will not affect serialization of PackageDescription types. Serialization is handled by converting PackageDescription types into separate, corresponding Codable types. The existing serialization types will remain as-is.
179
180
180
181
181
-
### Rename API added in SE-0435
182
-
The API in the newly-accepted [SE-0435](https://github.com/apple/swift-evolution/blob/main/proposals/0435-swiftpm-per-target-swift-language-version-setting.md) will change to use the _language mode_ terminology:
182
+
### Add `swiftLanguageMode()` to `SwiftSetting`
183
+
Add a new `swiftLanguageMode()` static function to `SwiftSetting` with the same behavior of `swiftLanguageBehavior()` added by [SE-0435](https://github.com/apple/swift-evolution/blob/main/proposals/0435-swiftpm-per-target-swift-language-version-setting.md):
183
184
184
185
```swift
185
186
public struct SwiftSetting {
@@ -194,14 +195,30 @@ public struct SwiftSetting {
194
195
195
196
The name of the function is `swiftLanguageMode()` instead of `languageMode()` to keep naming consistent with the `swiftLanguageModes` parameter of the Package init method. The parameter label `mode` is used to follow the precedent set by `interoperabilityMode()` in `SwiftSetting`.
196
197
198
+
Deprecate the `swiftLanguageVersion()` setting added by SE-0435 with a `renamed` annotation to provide a fix-it for developers who have adopted this API in pre-release versions of Swift 6.0.:
The new Package `init` method and obsoleting of the existing `init` method will cause source breakage for package manifests that specify the existing `swiftLanguageVersions` parameter when updating to swift tools version 6.0
199
216
200
217
A search of manifest files in public repositories suggests that about 10% of manifest files will encounter this breakage.
201
218
202
219
Because the obsoleted `init` method is annotated as `renamed` the compiler will automatically provide a fix-it to update to the new `init` method.
203
220
204
-
Renaming the public `swiftLanguageVersions` property of `Package` preserves backwards compatibility by introducing a computed property with that name. Because this proposal already contains a necessary breaking change as detailed above, the computed property will also be marked as obsoleted in 6.0 and annotated as `renamed` to provide a fix-it.
221
+
Renaming the public `swiftLanguageVersions` property of `Package` preserves backwards compatibility by introducing a computed property with that name. The computed property will be marked as `deprecated` in 6.0 and annotated as `renamed` to provide a fix-it.
205
222
206
223
Searching manifest files in public repositories suggests that accessing the `swiftLanguageVersions` property directly is not common. Making both breaking changes at once results in applying at most two fix-its to a manifest file instead of one.
207
224
@@ -211,7 +228,7 @@ This proposal has no effect on ABI stability.
211
228
## Future directions
212
229
This proposal originally included the proposed addition of a `languageMode()` compilation condition to further standardize on the terminology and allow the compiler to check for valid language mode values.
213
230
214
-
That functionality has been removed from this proposal with the intent to pitch it seperately. Doing so keeps this proposal focused on the tools, including the source breaking API changes. The future direction is purely additive and would focus on the language change.
231
+
That functionality has been removed from this proposal with the intent to pitch it separately. Doing so keeps this proposal focused on the tools, including the source breaking API changes. The future direction is purely additive and would focus on the language change.
215
232
216
233
## Alternatives considered
217
234
@@ -223,7 +240,7 @@ The intent of this proposal is to formalize established terminology in tool opti
223
240
224
241
The term _language mode_ is a long-established term of art in the Swift community to describe this functionality in the compiler.
225
242
226
-
This includes the [blog post](https://www.swift.org/blog/swift-4.0-released/) annoucing the functionality as part of the release of Swift 4 in 2017 (emphasis added):
243
+
This includes the [blog post](https://www.swift.org/blog/swift-4.0-released/) announcing the functionality as part of the release of Swift 4 in 2017 (emphasis added):
227
244
228
245
> With Swift 4, you may not need to modify your code to use the new version of the compiler. The compiler supports two _language modes_…
229
246
@@ -263,4 +280,8 @@ On consideration, this concern is mitigated in two ways:
263
280
> _How do you enable Embedded Swift?_
264
281
> Pass the `-embedded` compiler flag to compile Embedded Swift.
265
282
266
-
Considering these alternatives, it seems likely that introducing a new term to replace the long-established term _language mode_ and potentially giving the existing term a new meaning would lead to more ambiguity than keeping and formalizing the existing meaning of _language mode_.
283
+
Considering these alternatives, it seems likely that introducing a new term to replace the long-established term _language mode_ and potentially giving the existing term a new meaning would lead to more ambiguity than keeping and formalizing the existing meaning of _language mode_.
284
+
285
+
## Acknowledgments
286
+
287
+
Thank you to Pavel Yaskevich for providing guidance and assistance in the implementation of this proposal.
0 commit comments