# Piecemeal adoption of Swift 6 improvements in Swift 5.x

**URL:** <https://forums.swift.org/t/piecemeal-adoption-of-swift-6-improvements-in-swift-5-x/57184>\
**Category:** Pitches\
**Created:** [May 6, 2022, 11:08pm UTC](https://forums.swift.org/t/piecemeal-adoption-of-swift-6-improvements-in-swift-5-x/57184 "2022-05-06T23:08:47Z")\
**Posts on this page:** 10\
**Page:** 3

<div class="post-metadata">

**Author:** ![Douglas\_Gregor](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/douglas_gregor/32/1362_2.png) [@Douglas\_Gregor](https://forums.swift.org/u/Douglas_Gregor)\
**Post date:** [May 24, 2022, 7:27pm UTC](https://forums.swift.org/t/piecemeal-adoption-of-swift-6-improvements-in-swift-5-x/57184/42 "2022-05-24T19:27:33Z")

</div>

> [@Douglas\_Gregor](#):
>
> Thank you everyone for the great feedback. I turned this into a proper proposal over at [Initial version by DougGregor · Pull Request #1660 · apple/swift-evolution · GitHub](https://github.com/apple/swift-evolution/pull/1660).

And for those interested in the implementation details, I have a pull request up at [[SE-0362] Piecemeal adoption of upcoming language improvements by DougGregor · Pull Request #59055 · apple/swift · GitHub](https://github.com/apple/swift/pull/59055) for the compiler pieces.

Doug

---

<div class="post-metadata">

**Author:** ![James\_Dempsey](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/james_dempsey/32/14336_2.png) [@James\_Dempsey](https://forums.swift.org/u/James_Dempsey)\
**Post date:** [June 2, 2022, 11:29pm UTC](https://forums.swift.org/t/piecemeal-adoption-of-swift-6-improvements-in-swift-5-x/57184/43 "2022-06-02T23:29:19Z")

</div>

I realize you have not put the proposal through the pitch phase yet but I had one suggestion to consider before you do.

All compiler conditions except `canImport()` omit the word `is` or `has` to define the condition.

I think `#if feature(FeatureX)` is as clear as `#if targetEnvironment(simulator)`, `#if compiler(swift >= 5.1)` or any of the other existing conditions without a verb.

The condition `canImport()` seems to be an outlier because there isn't a single noun that adequately explains the condition.

Possibly consider `#if feature()` instead of `#if hasFeature()` since it follows the existing naming convention of all but one compilation condition and seems it would be just as clear and understandable to read.

---

<div class="post-metadata">

**Author:** ![philipturner](https://avatars.discourse-cdn.com/v4/letter/p/b5e925/32.png) [@philipturner](https://forums.swift.org/u/philipturner)\
**Post date:** [June 2, 2022, 11:57pm UTC](https://forums.swift.org/t/piecemeal-adoption-of-swift-6-improvements-in-swift-5-x/57184/44 "2022-06-02T23:57:07Z")

</div>

> [@James\_Dempsey](#):
>
> `#if hasFeature()`

That sounds like a really concise way to phrase it. It would also be an alternative to using fragile build flags in package manifests. Import availabilities and (maybe) platforms are extremely dynamic; so are the plethora of Swift 6 features we want to test out in Swift 5. By dynamic, I mean it would take unreasonably long to make each one an official part of the Swift compiler and then support its specific build flag in the far future. We need something where support for the opt-in feature can be quickly added or dropped and not promised to be maintained indefinitely.

---

<div class="post-metadata">

**Author:** ![James\_Dempsey](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/james_dempsey/32/14336_2.png) [@James\_Dempsey](https://forums.swift.org/u/James_Dempsey)\
**Post date:** [June 3, 2022, 12:36am UTC](https://forums.swift.org/t/piecemeal-adoption-of-swift-6-improvements-in-swift-5-x/57184/45 "2022-06-03T00:36:21Z")

</div>

I don't know if you read through the full proposal Douglas Gregor has written up:

> [@Piecemeal adoption of Swift 6 improvements in Swift 5.x](https://forums.swift.org/t/piecemeal-adoption-of-swift-6-improvements-in-swift-5-x/57184/42):
>
> And for those interested in the implementation details, I have a pull request up at [[SE-0362] Piecemeal adoption of upcoming language improvements by DougGregor · Pull Request #59055 · apple/swift · GitHub](https://github.com/apple/swift/pull/59055) for the compiler pieces. Doug

I am guessing the proposal will go into pitch phase sometime after WWDC, since it is a pretty busy week for the core team, but I didn't want to forget my naming suggestion.

---

<div class="post-metadata">

**Author:** ![xwu](https://avatars.discourse-cdn.com/v4/letter/x/b487fb/32.png) [@xwu](https://forums.swift.org/u/xwu)\
**Post date:** [June 3, 2022, 2:47am UTC](https://forums.swift.org/t/piecemeal-adoption-of-swift-6-improvements-in-swift-5-x/57184/46 "2022-06-03T02:47:19Z")

</div>

> [@James\_Dempsey](#):
>
> All compiler conditions except `canImport()` omit the word `is` or `has` to define the condition.

The only omitted verb is "is": there is only one target environment, compiler version, etc. at build time, so the conditional asks what that target environment _is_, or what that compiler version _is_, etc. It would be inapt to write `#if feature`, by contrast, as one is not asking what "the" feature is at compile time, since there's more than one feature that may or may not be enabled just like there's more than one library that can or cannot be imported.

---

<div class="post-metadata">

**Author:** ![Douglas\_Gregor](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/douglas_gregor/32/1362_2.png) [@Douglas\_Gregor](https://forums.swift.org/u/Douglas_Gregor)\
**Post date:** [June 3, 2022, 5:58am UTC](https://forums.swift.org/t/piecemeal-adoption-of-swift-6-improvements-in-swift-5-x/57184/47 "2022-06-03T05:58:28Z")

</div>

> [@James\_Dempsey](#):
>
> I am guessing the proposal will go into pitch phase sometime after WWDC, since it is a pretty busy week for the core team, but I didn't want to forget my naming suggestion.

The core team generally avoids scheduling proposal reviews over the week of WWDC, since a large chunk of the community is focused on that conference. I expect this proposal to go into review shortly afterward based on the responses in this pitch.

Doug

---

<div class="post-metadata">

**Author:** ![wowbagger](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/wowbagger/32/13847_2.png) [@wowbagger](https://forums.swift.org/u/wowbagger)\
**Post date:** [June 4, 2022, 7:33am UTC](https://forums.swift.org/t/piecemeal-adoption-of-swift-6-improvements-in-swift-5-x/57184/48 "2022-06-04T07:33:01Z")

</div>

A bikeshed on `--enable-experimental-feature`: Would `--enable-experimental-future-feature` be better? I think it communicates an extra layer of caution needed, and the longer flag name adds a little bit more friction so people are (slightly) less inclined to use it.

Would it be a good idea to also add `--enable-all-(experimental-)future-features` to enable all, along with `--disable-(experimental-)future-feature` flags to opt out specific features when the former flag is set.

---

<div class="post-metadata">

**Author:** ![Douglas\_Gregor](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/douglas_gregor/32/1362_2.png) [@Douglas\_Gregor](https://forums.swift.org/u/Douglas_Gregor)\
**Post date:** [June 6, 2022, 9:08pm UTC](https://forums.swift.org/t/piecemeal-adoption-of-swift-6-improvements-in-swift-5-x/57184/49 "2022-06-06T21:08:23Z")

</div>

> [@wowbagger](#):
>
> A bikeshed on `--enable-experimental-feature` : Would `--enable-experimental-future-feature` be better?

I don't think so. Experimental features are not necessarily future features---they might turn out to be a bad idea, or get changed or renamed.

> [@wowbagger](#):
>
> Would it be a good idea to also add `--enable-all-(experimental-)future-features` to enable all

I don't think we should do that. These "future" features are source-breaking, so adding a new one into your build needs to be a deliberate choice... not something that comes from installing a new toolchain.

Doug

---

<div class="post-metadata">

**Author:** ![hborla](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/hborla/32/27563_2.png) [@hborla](https://forums.swift.org/u/hborla)\
**Post date:** [June 22, 2022, 8:31pm UTC](https://forums.swift.org/t/piecemeal-adoption-of-swift-6-improvements-in-swift-5-x/57184/50 "2022-06-22T20:31:09Z")

</div>

I've kicked this off for review [here](https://forums.swift.org/t/se-0362-piecemeal-adoption-of-future-language-improvements/58384). Thanks all for the discussion so far, and please take any further feedback over to the review thread!

---

<div class="post-metadata">

**Author:** ![John\_McCall](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/john_mccall/32/1351_2.png) [@John\_McCall](https://forums.swift.org/u/John_McCall)\
**Post date:** [June 22, 2022, 9:03pm UTC](https://forums.swift.org/t/piecemeal-adoption-of-swift-6-improvements-in-swift-5-x/57184/51 "2022-06-22T21:03:21Z")

</div>

Closed on June 22, 2022, 9:03pm UTC



[Previous page](https://forums.swift.org/t/piecemeal-adoption-of-swift-6-improvements-in-swift-5-x/57184.md?page=2)
