<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div dir="auto" class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div dir="auto" class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div dir="auto" class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div dir="auto" class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div dir="auto" class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div dir="auto" class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class="">Hi,</div><div class=""><br class=""></div><div class="">One of the Stage 1 goals of Swift 4 is source compatibility with Swift 3<font class="">,</font> but what does that precisely mean and how will we determine if the goal is achieved? <font class="">This is the current proposal of how this goal ties back to the Swift 3.x and Swift 4 releases. Is there anything else that’s missing or should be discussed?</font></div><div class=""><br class=""></div><div class=""><font class=""><div class=""><div class=""><br class=""></div></div></font></div><div class=""><ul class="MailOutline"><li class=""><font class=""><span class="">The</span><b class=""> source compatibility goal</b><span class=""> for Swift 4 means that sources that previously compiled with the Swift 3 compiler will continue to compile with no source modifications with the Swift 3.x and Swift 4 compilers.</span><b class=""> </b></font></li></ul><div class=""><br class=""></div><ul class="MailOutline"><li class=""><span class="" style="font-weight: 700; background-color: rgb(255, 255, 255);">Swift 3.x releases </span><span class="" style="background-color: rgb(255, 255, 255);"><font class="">have the goal of </font>source compatibility with Swift 3. </span><span class="" style="background-color: rgb(255, 255, 255);">This is the default mode and there is no compatibility flag.</span><span class="" style="background-color: rgb(255, 255, 255);"> </span></li><ul class=""><li class=""><span class="" style="background-color: rgb(255, 255, 255);">This means that Swift 3 code should be able to build with the Swift 3.x compiler without modification </span><font class="" style="background-color: rgb(255, 255, 255);">as much as practically possible</font><span class="" style="background-color: rgb(255, 255, 255);">. The same applies to SwiftPM packages with Swift 3 source code. </span><font class="" style="background-color: rgb(255, 255, 255);"> </font></li><li class=""><span class="" style="background-color: rgb(255, 255, 255);">Swift 3.x code will not necessarily compile with the Swift 3 compiler. For example, new language features could be added.</span></li></ul></ul><div class=""><br class=""></div><div class=""><ul class="MailOutline"><li class=""><font class=""><span class="" style="background-color: rgb(255, 255, 255);">The <b class="">Swift 4 compiler</b> will include a language compatibility flag </span><font face="Menlo" class="" style="background-color: rgb(255, 255, 255);">-swift-version</font><span class="" style="background-color: rgb(255, 255, 255);"> that accepts</span><font face="Menlo" class="" style="background-color: rgb(255, 255, 255);"> 3</font><span class="" style="background-color: rgb(255, 255, 255);"> or </span><font face="Menlo" class="" style="background-color: rgb(255, 255, 255);">4</font><span class="" style="background-color: rgb(255, 255, 255);"> as arguments and controls the compatibility mode (</span><a href="https://bugs.swift.org/browse/SR-2582" class="" style="background-color: rgb(255, 255, 255);">SR- 2582</a><span class="" style="background-color: rgb(255, 255, 255);">).</span></font></li><ul class=""><li class=""><span class="" style="background-color: rgb(255, 255, 255);">The</span><span class="" style="background-color: rgb(255, 255, 255);"> </span><font face="Menlo" class="" style="background-color: rgb(255, 255, 255);">-swift-version 3</font><span class="" style="background-color: rgb(255, 255, 255);"> </span><span class="" style="background-color: rgb(255, 255, 255);">compatibility mode has <font class="">the goal of source compatibility as much as practically possible </font>with Swift 3.x (including 3, 3.0.x, 3.x). </span></li><li class=""><span class="" style="background-color: rgb(255, 255, 255);"><font class=""><span class="">The</span><span class=""> </span><font face="Menlo" class="">-swift-version 4 </font><font class="">compatibility allows <font class="">approved</font> </font><font class="">source code breakages from Swift 3.x (including 3, 3.0.x, 3.x). Proposed source breaking changes should be discussed on swift-evolution and highlighted in evolution proposals.</font></font></span></li><li class=""><font class=""><span class="" style="background-color: rgb(255, 255, 255);">All the sources in a module (e.g, SwiftPM packages, targets in Xcode) will be built in the same compatibility </span><span class="" style="background-color: rgb(255, 255, 255);">mode, but modules built with different compatibility modes can be linked </span><span class="" style="background-color: rgb(255, 255, 255);">into a single binary and will interoperate. </span></font></li><li class=""><span class="" style="background-color: rgb(255, 255, 255);"><font class="">Thus a</font> module can be migrated from Swift 3 to 3.x to 4 independently of its dependencies.</span></li><li class=""><span class="" style="background-color: rgb(255, 255, 255);">The Swift Package Manager will allow package authors to specify a list of compatibility modes.</span></li><li class=""><span class="" style="background-color: rgb(255, 255, 255);">The Swift compiler already provides a mechanism for conditional compilation based on the compiler version with the <font face="Menlo" class="">#if swift</font> syntax. </span><span class=""><a href="https://github.com/apple/swift-evolution/blob/master/proposals/0020-if-swift-version.md" class="">SE-0020</a>. </span><span class="" style="background-color: rgb(255, 255, 255);">Swift 4 will also provide mechanisms to conditionalize code based on the compatibility version. </span></li><li class=""><span class="" style="background-color: rgb(255, 255, 255);">The <font face="Menlo" class="">@available(...) </font>attribute has been expanded to support the swift language version with <span class=""><a href="https://github.com/apple/swift-evolution/blob/master/proposals/0141-available-by-swift-version.md" class="">SE-0141</a>. </span>For example, <span class="" style="font-family: Menlo;">@available(swift 3)</span>.</span></li></ul></ul></div></div></div></div></div></div></div></div><div dir="auto" class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div dir="auto" class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div dir="auto" class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div dir="auto" class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div dir="auto" class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div dir="auto" class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><div class=""><br class=""></div><div class=""><ul class="MailOutline"><li class=""><font class=""><b class="">Maintaining source compatibility with Swift 3</b> <b class="">in practice</b> while continuing development is not always clear-cut. It often comes down to tradeoffs. Let’s review a few cases.</font></li><ul class=""><li class=""><font class="">New features may become available if they do not take up syntactic space that might be commonly used by existing Swift code. </font></li><li class=""><font class=""><font class="">If a bug fix breaks source in a fringe case </font>as determined by a scan of existing source, the benefit might outweigh the cost and it could be allowed.</font></li><li class=""><font class="">Changes to existing APIs have high bar to clear as they should provide a significant benefit to clients and have minimal impact on existing, real-life code. <font class="">These changes should be considered for inclusion in the </font></font><font class=""><font face="Menlo" class="">-swift-version 4 </font><font class="">compatibility mode of the Swift 4 compiler instead.</font></font></li><li class=""><font class="">New warnings are allowed because they do not require source code changes.</font></li><li class=""><b class="">To summarize,</b><font class=""> any proposed source breakage<font class=""> from Swift 3 for the Swift 3.x compilers or the <font face="Menlo" class="" style="background-color: rgb(255, 255, 255);">-swift-version 3</font><span class="" style="background-color: rgb(255, 255, 255);"> </span><span class="" style="background-color: rgb(255, 255, 255);">compatibility mode of the Swift 4 compiler</span></font>, should be small in scope of code affected and weighed against the goals of source compatibility described above. It should be approved on swift-evolution. </font></li></ul></ul><div class=""><br class=""></div></div></div><div class=""><ul class="MailOutline"><li class=""><b class="">For Apple Platforms</b>, source compatibility can also be affected by changes to the Apple SDKs. <font class=""> Last year</font>, Swift 2.3 required a migration from Swift 2.2 to account for changes in the SDKs even though no language changes were introduced. This year, source compatibility is defined more strictly to require that the Apple SDKs only add source compatible changes when used with the Swift 3.x compilers or when used with the Swift 3 compatibility mode (<span class="" style="background-color: rgb(255, 255, 255);"><font face="Menlo" class="">-swift-version 3</font>)</span> in the Swift 4 compiler. <font class="">T<font class="">he ‘API notes’ feature has been augmented and can now express how an API is imported for a specific Swift version. This feature allows the view of the evolved Apple SDKs to stay the same as with Swift 3 when Swift 3 source compatibility is expected.</font></font></li></ul><div class=""><br class=""></div></div></div><div class=""><div dir="auto" class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><div class="page" title="Page 2"><div class="section" style="background-color: rgb(255, 255, 255);"><div class="layoutArea"><div class="column"></div></div></div></div></div><div class="page" title="Page 3"><br class=""></div><div class="page" title="Page 3">Thanks,</div><div class="page" title="Page 3">Ewa</div></div></div></div></div></div></div></div></body></html>