<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""><br class=""></div><div><br class=""><blockquote type="cite" class=""><div class="">On Jan 5, 2018, at 23:43, David Hart <<a href="mailto:david@hartbit.com" class="">david@hartbit.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">I was really surprised when I saw that the release of 4.0 introduced this 3.2 version to mean “the 4.0 compiler running in 3.1 compatibility mode”. So of course, I’m even more surprised to see a new 3.3 version. I find it very counter-intuitive. It also means we will continue to have to increment all previous Swift language versions from now on whenever a new compiler is released:</span><div style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br class=""></div><div style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">Swift 3.4 = Swift 5 compiler in Swift 3 compatibility mode</div><div style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">Swift 4.2 = Swift 5 compiler in Swift 4 compatibility mode</div><div style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">Swift 3.5 = Swift 5.1 compiler in Swift 3 compatibility mode</div><div style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">Swift 4.3 = Swift 5.1 compiler in Swift 4 compatibility mode</div></div></blockquote><div><br class=""></div><div>The most common use of `#if swift` is `#if swift(>=4.0)`, to check for things that actually changed in Swift 4 and <i class="">not</i> in the 3 compatibility modes. I agree that the "subtraction" going on here is very weird, though, and of course it leads to this problem when you're actually trying to test the compiler release rather than the language mode.</div><div><br class=""></div><div>(Your predictions are right, though, if nothing else here changes: <a href="https://github.com/apple/swift/pull/13767" class="">https://github.com/apple/swift/pull/13767</a>)</div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><div class="">I have the impression that what we really need is a different directive to test for the compiler version:</div><div class=""><br class=""></div><div class="">#if compiler(>=4.1)</div><div class="">// Swift 3.3</div><div class="">// Swift 4.1</div><div class="">#endif</div></div></blockquote><div><br class=""></div><div>That certainly seems reasonable. If that's the direction we want to go, the next question is whether it's important enough to put through swift-evolution in time for Swift 4.1, or whether it could wait for Swift 5. (I'd also love if someone <i class="">else</i> shepherded that proposal and implementation through. I could put it up as a StarterBug/StarterProposal.)</div><div><br class=""></div><div>Jordan</div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><div class=""><div class=""><div class=""><br class="">On 6 Jan 2018, at 01:19, Jordan Rose via swift-build-dev <<a href="mailto:swift-build-dev@swift.org" class="">swift-build-dev@swift.org</a>> wrote:<br class=""><br class=""></div><blockquote type="cite" class=""><div class="">Hi, all. Swift 4.1 is off on its own branch and going well, but we never quite came up with an answer for a particular problem developers might have: "am I running a Swift 4.1<span class="Apple-converted-space"> </span><i class="">compiler?".</i><div class=""><i class=""><br class=""></i></div><blockquote class="" style="margin: 0px 0px 0px 40px; border: none; padding: 0px;"><div class="">#if swift(>=3.2)</div></blockquote><blockquote class="" style="margin: 0px 0px 0px 40px; border: none; padding: 0px;"><div class="">// Swift 3.2 (4.0 in compatibility mode)</div><div class="">// Swift 3.3 (4.1 in compatibility mode)</div><div class="">// Swift 4.0</div><div class="">// Swift 4.1</div><div class="">#endif</div><div class=""><br class=""></div><div class="">#if swift(>=3.3)</div><div class="">// Swift 3.3 (4.1 compatibily mode)</div><div class="">// Swift 4.0</div><div class="">// Swift 4.1</div><div class="">// this one is probably not very useful</div><div class="">#endif</div><div class=""><br class=""></div><div class="">#if swift(>=4.0)</div><div class="">// Swift 4.0</div><div class="">// Swift 4.1</div><div class="">#endif</div></blockquote><div class=""><br class=""></div><blockquote class="" style="margin: 0px 0px 0px 40px; border: none; padding: 0px;">#if ???</blockquote><blockquote class="" style="margin: 0px 0px 0px 40px; border: none; padding: 0px;">// Swift 3.3</blockquote><blockquote class="" style="margin: 0px 0px 0px 40px; border: none; padding: 0px;">// Swift 4.1</blockquote><blockquote class="" style="margin: 0px 0px 0px 40px; border: none; padding: 0px;">#endif</blockquote><div class=""><br class=""></div>I don't think this is going to come up a<span class="Apple-converted-space"> </span><i class="">lot,</i> but given that we do have changes to the standard library and to the language, I can see people wanting it. Right now the only way to do it is the rather unwieldy:<div class=""><br class=""></div><blockquote class="" style="margin: 0px 0px 0px 40px; border: none; padding: 0px;"><div class="">#if swift(>=4.1) || (swift(>=3.3) && !swift(>=4.0))</div><div class="">print("new")</div><div class="">#else</div><div class="">print("old")</div><div class="">#endif</div></blockquote><div class=""><br class=""></div>Do we need something better here, or do you think people will be okay with this? I'm realizing I don't really know how many people try to keep their libraries working across Swift versions<span class="Apple-converted-space"> </span><i class="">and</i> run into compatibility issues. <br class=""><div class=""><div class=""><div class=""><div class=""><br class=""></div><div class="">(Strictly speaking this problem is already present with Swift 4.0.2 with 3.2.2 compatibility mode, but that's much less likely to come up.)</div></div></div></div><div class=""><br class=""></div><div class="">Jordan</div></div></blockquote><blockquote type="cite" class=""><div class=""><span class="">_______________________________________________</span><br class=""><span class="">swift-build-dev mailing list</span><br class=""><span class=""><a href="mailto:swift-build-dev@swift.org" class="">swift-build-dev@swift.org</a></span><br class=""><span class=""><a href="https://lists.swift.org/mailman/listinfo/swift-build-dev" class="">https://lists.swift.org/mailman/listinfo/swift-build-dev</a></span></div></blockquote></div></div></div></div></blockquote></div><br class=""></body></html>