<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="">Thanks for the info, Alan!</div><div class=""><br class=""></div><div class="">On `swift(<4.0)`: I think originally we were even more restrictive about how people used `#if swift`, not even allowing !, &&, and ||. Without those restrictions, allowing a `swift(<x.y)` seems reasonable. <i class="">However,</i> I don't think that really makes the compound condition significantly nicer. (> and <= are very deliberately not included, because people always forget point releases.)</div><div class=""><br class=""></div><div class="">Jordan</div><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Jan 5, 2018, at 17:22, Alan Zeino <<a href="mailto:alanz@uber.com" class="">alanz@uber.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="">Hey Jordan,</span><div class="" 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;"><br class=""></div><div class="" 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;">We tend to have to do major migrations of our Swift codebase, so I might be able to help. For context at last count (February 2017 was the last time I checked) we had 1.4m lines of Swift across our apps.</div><div class="" 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;"><br class=""></div><div class="" 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;">This means that when we migrate, we tend to have to chose the smallest possible scope for necessity reasons. For example when Swift 3.0 was available, we went to 2.3 first and it took a few months before we were on 3.0.</div><div class="" 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;"><br class=""></div><div class="" 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;">When 4.0 was available we went to 3.2 first (with many, many #if statements) and it took a few months before we went to 4.0; which we did by landing many months worth of #if statements to switch between 3.2/4.0 right up until the 4.0 switch.</div><div class="" 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;"><br class=""></div><div class="" 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;">To answer the last question first, the larger the codebase the more likely you will be to want to do your swift migrations piecemeal with many small changes until you can build a fully–compatible–with–the–new–version executable. </div><div class="" 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;"><br class=""></div><div class="" 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;">This is even more important for open source libraries, who struggle with either having entire forked branches for swift versions (which means fixes sometimes have to be committed to more than one branch), or many #if statements littered in their codebase.</div><div class="" 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;"><br class=""></div><div class="" 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;">As for this issue, the main improvement here would be to be able to use<span class="Apple-converted-space"> </span><font face="Menlo" class="">></font><span class="Apple-converted-space"> </span>and<span class="Apple-converted-space"> </span><font face="Menlo" class=""><</font><span class="Apple-converted-space"> </span>in these statements. The first time I had to do one of these large migrations I found it more difficult to reason and read the cases where you had to do this:</div><div class="" 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;"><br class=""></div><div class="" 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;">#if !swift(>=3.2)<br class="">/* code */</div><div class="" 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;">#endif</div><div class="" 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;"><br class=""></div><div class="" 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;">…when it would be a little easier to grok what’s happening if it were possible to do this:</div><div class="" 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;"><br class=""></div><div class="" 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;"><div class="">#if swift(<3.2)<br class="">/* code */</div><div class="">#endif</div><div class=""><br class=""></div><div class="">In your example, it could be a little simpler if the unary requirement here was relaxed (though I’m sure there’s a good reason why it’s the way it is!).</div><div class=""><br class=""></div><div class="">If I’m reading this correctly (sorry if my interval notation is wrong it’s been a while) the bounds here would be:</div><div class=""><br class=""></div><div class=""><div class="" style="margin: 0px; font-stretch: normal; font-size: 13px; line-height: normal; font-family: Menlo; color: rgb(81, 195, 79); background-color: rgb(41, 43, 54);"><span class="" style="color: rgb(231, 232, 235);"> </span><span class="" style="color: rgb(231, 232, 235);"> </span>// n >= 4.1</div><div class="" style="margin: 0px; font-stretch: normal; font-size: 13px; line-height: normal; font-family: Menlo; color: rgb(231, 232, 235); background-color: rgb(41, 43, 54);"> <span class="Apple-converted-space"> </span><span class="" style="color: rgb(81, 195, 79);">// or</span></div><div class="" style="margin: 0px; font-stretch: normal; font-size: 13px; line-height: normal; font-family: Menlo; color: rgb(81, 195, 79); background-color: rgb(41, 43, 54);"><span class="" style="color: rgb(231, 232, 235);"> <span class="Apple-converted-space"> </span></span>// 3.3 >= n < 4.0</div><div class="" style="margin: 0px; font-stretch: normal; font-size: 13px; line-height: normal; font-family: Menlo; color: rgb(231, 232, 235); background-color: rgb(41, 43, 54);"> <span class="Apple-converted-space"> </span><span class="" style="color: rgb(211, 141, 93);">#if</span><span class="Apple-converted-space"> </span><span class="" style="color: rgb(211, 141, 93);">swift</span>(>=<span class="" style="color: rgb(0, 170, 163);">4.1</span>) || (<span class="" style="color: rgb(211, 141, 93);">swift</span>(>=<span class="" style="color: rgb(0, 170, 163);">3.3</span>) && !<span class="" style="color: rgb(211, 141, 93);">swift</span>(>=<span class="" style="color: rgb(0, 170, 163);">4.0</span>))</div><div class="" style="margin: 0px; font-stretch: normal; font-size: 13px; line-height: normal; font-family: Menlo; color: rgb(231, 232, 235); background-color: rgb(41, 43, 54);"> <span class="Apple-converted-space"> </span><span class="" style="color: rgb(41, 160, 159);">print</span>(<span class="" style="color: rgb(222, 58, 60);">"asdf"</span>)</div><div class="" style="margin: 0px; font-stretch: normal; font-size: 13px; line-height: normal; font-family: Menlo; color: rgb(231, 232, 235); background-color: rgb(41, 43, 54);"> <span class="Apple-converted-space"> </span><span class="" style="color: rgb(211, 141, 93);">#endif</span></div></div><div class=""><br class=""></div><div class="">But if it were possible to use > and <, it would read:</div><div class=""><br class=""></div><div class=""><div class="" style="margin: 0px; font-stretch: normal; font-size: 13px; line-height: normal; font-family: Menlo; color: rgb(231, 232, 235); background-color: rgb(41, 43, 54);"><span class="" style="color: rgb(211, 141, 93);"> #if</span><span class="Apple-converted-space"> </span>(<span class="" style="color: rgb(211, 141, 93);">swift</span>(>=<span class="" style="color: rgb(0, 170, 163);">3.3</span>) &&<span class="Apple-converted-space"> </span><span class="" style="color: rgb(211, 141, 93);">swift</span>(<u class=""><</u><span class="" style="color: rgb(0, 170, 163);">4.0</span>)) ||<span class="Apple-converted-space"> </span><span class="" style="color: rgb(211, 141, 93);">swift</span>(>=<span class="" style="color: rgb(0, 170, 163);">4.1</span>)</div><div class="" style="margin: 0px; font-stretch: normal; font-size: 13px; line-height: normal; font-family: Menlo; color: rgb(231, 232, 235); background-color: rgb(41, 43, 54);"> <span class="Apple-converted-space"> </span><span class="" style="color: rgb(41, 160, 159);">print</span>(<span class="" style="color: rgb(222, 58, 60);">"asdf"</span>)</div><div class="" style="margin: 0px; font-stretch: normal; font-size: 13px; line-height: normal; font-family: Menlo; color: rgb(231, 232, 235); background-color: rgb(41, 43, 54);"> <span class="Apple-converted-space"> </span><span class="" style="color: rgb(211, 141, 93);">#endif</span></div></div><div class=""><br class=""></div><div class="">(I don’t know why Mail.app is making the < above look like a less than or equal to symbol ≤)</div><div class=""><br class=""></div><div class="">I find it a little easier to read it this way, because the negation with ! changes my thinking from ‘interval’ to ‘interval plus… not something in this interval’.</div><div class=""><br class=""></div><div class="">Overall, while I think that most people here know that these compatibility versions are really ‘the old code built with the latest compiler’, most tend to ignore this fact so we try not to worry about it much and trust the compiler a lot here to do the right thing. We also try to only support one Xcode version at Uber at a time (and so one swift compiler toolchain), which tends to narrow the scope of the ‘what version of Swift will this code compile for’ question.</div><div class=""><br class=""></div><div class="">Hope this helps!</div><div class=""><br class=""></div><div class="">Alan</div><div class=""><br class=""></div><div class=""><br class=""><blockquote type="cite" class=""><div class="">On Jan 5, 2018, at 4:19 PM, Jordan Rose via swift-build-dev <<a href="mailto:swift-build-dev@swift.org" class="">swift-build-dev@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">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>_______________________________________________<br class="">swift-build-dev mailing list<br class=""><a href="mailto:swift-build-dev@swift.org" class="">swift-build-dev@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-build-dev" class="">https://lists.swift.org/mailman/listinfo/swift-build-dev</a></div></blockquote></div></div></div></blockquote></div><br class=""></body></html>