<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="">(I already sent this to swift-evolution yesterday but cross-posting.)</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>&nbsp;but what does that precisely mean and how will we determine if the goal is achieved? &nbsp;<font class="">This is the current proposal&nbsp;of how this goal ties back to the Swift 3.x and Swift 4 releases. &nbsp;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="">&nbsp;source compatibility goal</b><span class="">&nbsp;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="">&nbsp;&nbsp;</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&nbsp;</span><span class="" style="background-color: rgb(255, 255, 255);"><font class="">have the goal of&nbsp;</font>source compatibility with Swift 3. &nbsp;</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);">&nbsp;&nbsp;</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&nbsp;</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.&nbsp;</span><font class="" style="background-color: rgb(255, 255, 255);">&nbsp;</font></li><li class=""><span class="" style="background-color: rgb(255, 255, 255);">Swift 3.x code will not&nbsp;necessarily compile with the Swift 3 compiler. &nbsp;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&nbsp;<b class="">Swift 4 compiler</b>&nbsp;will include a language compatibility flag&nbsp;</span><font face="Menlo" class="" style="background-color: rgb(255, 255, 255);">-swift-version</font><span class="" style="background-color: rgb(255, 255, 255);">&nbsp;that accepts</span><font face="Menlo" class="" style="background-color: rgb(255, 255, 255);">&nbsp;3</font><span class="" style="background-color: rgb(255, 255, 255);">&nbsp;or&nbsp;</span><font face="Menlo" class="" style="background-color: rgb(255, 255, 255);">4</font><span class="" style="background-color: rgb(255, 255, 255);">&nbsp;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);">&nbsp;</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);">&nbsp;</span><span class="" style="background-color: rgb(255, 255, 255);">compatibility mode has&nbsp;<font class="">the goal of source compatibility&nbsp;as much as practically possible&nbsp;</font>with Swift 3.x (including 3, 3.0.x, 3.x).&nbsp;</span></li><li class=""><span class="" style="background-color: rgb(255, 255, 255);"><font class=""><span class="">The</span><span class="">&nbsp;</span><font face="Menlo" class="">-swift-version 4&nbsp;</font><font class="">compatibility allows&nbsp;<font class="">approved</font>&nbsp;</font><font class="">source code breakages from Swift 3.x (including 3, 3.0.x, 3.x). &nbsp;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, &nbsp;SwiftPM packages, targets in Xcode) will be built in the same compatibility&nbsp;</span><span class="" style="background-color: rgb(255, 255, 255);">mode, but modules built with different compatibility modes can be linked&nbsp;</span><span class="" style="background-color: rgb(255, 255, 255);">into a single binary and will interoperate.&nbsp;</span></font></li><li class=""><span class="" style="background-color: rgb(255, 255, 255);"><font class="">Thus a</font>&nbsp;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&nbsp;<font face="Menlo" class="">#if swift</font>&nbsp;syntax.&nbsp;</span><span class=""><a href="https://github.com/apple/swift-evolution/blob/master/proposals/0020-if-swift-version.md" class="">SE-0020</a>. &nbsp;</span><span class="" style="background-color: rgb(255, 255, 255);">Swift 4 will also provide mechanisms to conditionalize code based on the compatibility version.&nbsp;</span></li><li class=""><span class="" style="background-color: rgb(255, 255, 255);">The&nbsp;<font face="Menlo" class="">@available(...)&nbsp;</font>attribute has been expanded to support the swift language version with&nbsp;<span class=""><a href="https://github.com/apple/swift-evolution/blob/master/proposals/0141-available-by-swift-version.md" class="">SE-0141</a>.&nbsp;</span>For example,&nbsp;<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&nbsp;compatibility with Swift 3</b>&nbsp;<b class="">in practice</b>&nbsp;while continuing development is not always clear-cut. &nbsp;It often&nbsp;comes down to tradeoffs. &nbsp;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.&nbsp;</font></li><li class=""><font class=""><font class="">If a bug fix breaks source in a fringe case&nbsp;</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. &nbsp;<font class="">These changes should be considered for&nbsp;inclusion in the&nbsp;</font></font><font class=""><font face="Menlo" class="">-swift-version 4&nbsp;</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="">&nbsp;any proposed source breakage<font class="">&nbsp;from Swift 3 for the Swift 3.x compilers or the&nbsp;<font face="Menlo" class="" style="background-color: rgb(255, 255, 255);">-swift-version 3</font><span class="" style="background-color: rgb(255, 255, 255);">&nbsp;</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&nbsp;should be approved on swift-evolution.&nbsp;</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.&nbsp;<font class="">&nbsp;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. &nbsp;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>&nbsp;in the Swift 4 compiler. &nbsp;<font class="">T<font class="">he &nbsp;‘API notes’ feature has been augmented and can now express how an API is imported for a specific Swift version. &nbsp;This feature allows the view of the evolved Apple SDKs to stay the same as with Swift 3 when Swift 3 source&nbsp;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>