Skip to content

Commit 27258ad

Browse files
Incorporate LSG feedback
- Make swiftLanguageVersions property deprecated not obsoleted - Deprecate Swift setting added in SE-0435 in favor of renamed setting - Add Acknowledgments section - Fix typos
1 parent 2993e77 commit 27258ad

File tree

1 file changed

+40
-19
lines changed

1 file changed

+40
-19
lines changed

proposals/nnnn-formalize-language-mode-terminology.md

Lines changed: 40 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ The **Alternatives Considered** section contains a more detailed discussion of t
2222
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.
2323

2424
#### 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.
2626

2727
### Swift Package Manager
2828
Introduce four Swift Package Manager API changes limited to manifests \>= 6.0:
@@ -46,10 +46,10 @@ Package(
4646

4747
Add a new `init` method to `Package` with the following changes from the current `init` method:
4848

49-
- The paramater `swiftLanguageVersions` is renamed to `swiftLanguageModes`
49+
- The parameter `swiftLanguageVersions` is renamed to `swiftLanguageModes`
5050
- The parameter type is now an optional array of `SwiftLanguageMode` values instead of `SwiftVersion` values
5151

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.
5353

5454
#### 2. Rename `swiftLanguageVersions` property to `swiftLanguageModes`
5555
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
5959
Rename the `SwiftVersion` enum to `SwiftLanguageMode`. Add `SwiftVersion` as a type alias for backwards compatibility.
6060

6161

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`
6363

6464
```swift
6565
public struct SwiftSetting {
@@ -72,7 +72,7 @@ public struct SwiftSetting {
7272
)
7373
```
7474

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.
7676

7777
#### Naming note
7878

@@ -99,7 +99,7 @@ The `-swift-version` option will continue to work as it currently does, preservi
9999

100100
The `-language-mode` option will be presented in the compiler help.
101101

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.
103103

104104
### Swift Package Manager
105105
Proposed Swift Package Manager API changes are limited to manifests \>= 6.0:
@@ -123,7 +123,7 @@ Package(
123123
```
124124

125125

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:
127127

128128
```
129129
@available(_PackageDescription, introduced: 5.3, obsoleted: 6, renamed:
@@ -157,29 +157,30 @@ See the **Source compatibiity** section for more details about this change.
157157
### Rename `swiftLanguageVersions` property to `swiftLanguageModes`
158158
Rename the `Package` public property `swiftLanguageVersions` to `swiftLanguageModes`. Introduce a computed property named `swiftLanguageModes` that accesses the renamed stored property for backwards compatibility.
159159
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`.
161161
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.
164165
165166
```swift
166-
@available(_PackageDescription, obsoleted: 6, renamed: "swiftLanguageModes")
167+
@available(_PackageDescription, deprecated: 6.0, renamed: "swiftLanguageModes")
167168
public var swiftLanguageVersions: [SwiftVersion]? {
168169
get { swiftLanguageModes }
169170
set { swiftLanguageModes = newValue }
170171
}
171172
```
172173
173-
See the **Source compatibiity** section for more details about this change.
174+
See the **Source compatibility** section for more details about this change.
174175
175176
### Rename `SwiftVersion` enum to `SwiftLanguageMode`
176177
Rename the existing `SwiftVersion` enum to `SwiftLanguageMode` with `SwiftVersion` added back as a type alias for backwards compatibility.
177178
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.
179180
180181
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):
183184
184185
```swift
185186
public struct SwiftSetting {
@@ -194,14 +195,30 @@ public struct SwiftSetting {
194195
195196
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`.
196197
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.:
199+
200+
```swift
201+
public struct SwiftSetting {
202+
// ... other settings
203+
204+
@available(_PackageDescription, introduced: 6.0, deprecated: 6.0, renamed: "swiftLanguageMode(_:_:)")
205+
public static func swiftLanguageVersion(
206+
_ version: SwiftVersion,
207+
_ condition: BuildSettingCondition? = nil
208+
) -> SwiftSetting {
209+
...
210+
}
211+
}
212+
```
213+
197214
## Source compatibility
198215
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
199216
200217
A search of manifest files in public repositories suggests that about 10% of manifest files will encounter this breakage.
201218
202219
Because the obsoleted `init` method is annotated as `renamed` the compiler will automatically provide a fix-it to update to the new `init` method.
203220
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.
205222
206223
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.
207224
@@ -211,7 +228,7 @@ This proposal has no effect on ABI stability.
211228
## Future directions
212229
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.
213230
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.
215232
216233
## Alternatives considered
217234
@@ -223,7 +240,7 @@ The intent of this proposal is to formalize established terminology in tool opti
223240
224241
The term _language mode_ is a long-established term of art in the Swift community to describe this functionality in the compiler.
225242
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):
227244
228245
> 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_…
229246
@@ -263,4 +280,8 @@ On consideration, this concern is mitigated in two ways:
263280
> _How do you enable Embedded Swift?_
264281
> Pass the `-embedded` compiler flag to compile Embedded Swift.
265282
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

Comments
 (0)