<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=""><br class=""><div><blockquote type="cite" class=""><div class="">On Oct 22, 2016, at 2:44 PM, Richard Wei via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi,<div class=""><br class=""></div><div class="">Foundation in 3.0-RELEASE didn't fully resolve the renaming in SE-0086, so we have `RegularExpression` on Linux and `NSRegularExpression` on macOS. The naming is now unified in Swift 3.0.1, but there doesn’t seem to be a possible way to resolve the code breaking change. Consider the example below:</div></div></div></blockquote><div><br class=""></div>+1. &nbsp;Assuming there are no major objections, I don’t think this needs a full evolution cycle. &nbsp;This seems like a bug fix to me.</div><div><br class=""></div><div>-Chris<br class=""><div><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><br class=""></div><div class="">Currently the following code is only compatible with 3.0-RELEASE, because RegularExpression on Linux becomes NSRegularExpression in 3.0.1, while we cannot use `#if` to differentiate between 3.0 and 3.0.1.</div><div class=""><br class=""></div><div class=""><span style="font-family: Menlo; font-size: 11px; color: rgb(120, 73, 42); font-variant-ligatures: no-common-ligatures;" class="">&nbsp; #if</span><span style="font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures;" class="">&nbsp;!</span><span style="font-family: Menlo; font-size: 11px; color: rgb(120, 73, 42); font-variant-ligatures: no-common-ligatures;" class="">os</span><span style="font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures;" class="">(</span><span style="font-family: Menlo; font-size: 11px; color: rgb(120, 73, 42); font-variant-ligatures: no-common-ligatures;" class="">macOS</span><span style="font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures;" class="">)</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp;&nbsp;</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(186, 45, 162);" class="">let</span><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp;regex =&nbsp;</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(186, 45, 162);" class="">try</span><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp;RegularExpression(pattern: pattern, options: [ .dotMatchesLineSeparators ])</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp;&nbsp;</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(120, 73, 42);" class="">#else</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp;&nbsp;</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(186, 45, 162);" class="">let</span><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp;regex =&nbsp;</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(186, 45, 162);" class="">try</span><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp;</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);" class="">NSRegularExpression</span><span style="font-variant-ligatures: no-common-ligatures;" class="">(pattern: pattern, options: [ .</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);" class="">dotMatchesLineSeparators</span><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp;])</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp;&nbsp;</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(120, 73, 42);" class="">#endif</span></div><div class=""><br class=""></div><div class=""><b class="">Proposed solution:</b></div><div class=""><b class=""><br class=""></b></div><div class="">If `#if swift(&gt;=)` can take the third version component, we can make the code compatible with 3.0.1 by the following:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp;&nbsp;</span><span style="color: rgb(120, 73, 42); font-variant-ligatures: no-common-ligatures;" class="">#if</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="color: rgb(120, 73, 42); font-variant-ligatures: no-common-ligatures;" class="">os</span><span style="font-variant-ligatures: no-common-ligatures;" class="">(</span><span style="color: rgb(120, 73, 42); font-variant-ligatures: no-common-ligatures;" class="">macOS</span><span style="font-variant-ligatures: no-common-ligatures;" class="">) || </span><span style="color: rgb(120, 73, 42); font-variant-ligatures: no-common-ligatures;" class="">swift</span><span style="font-variant-ligatures: no-common-ligatures;" class="">(&gt;=</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);" class="">3.0</span><span style="font-variant-ligatures: no-common-ligatures;" class="">.</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);" class="">1</span><span style="font-variant-ligatures: no-common-ligatures;" class="">)</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: rgb(186, 45, 162);" class="">&nbsp; let</span><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp;regex =&nbsp;</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(186, 45, 162);" class="">try</span><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp;</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);" class="">NSRegularExpression</span><span style="font-variant-ligatures: no-common-ligatures;" class="">(pattern: pattern, options: [ .</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);" class="">dotMatchesLineSeparators</span><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp;])</span></span>&nbsp;&nbsp;</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp;&nbsp;</span><span style="font-variant-ligatures: no-common-ligatures; color: #78492a" class="">#else</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #78492a" class=""><span style="font-variant-ligatures: no-common-ligatures; color: rgb(186, 45, 162);" class="">&nbsp; let</span><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp;regex =&nbsp;</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(186, 45, 162);" class="">try</span><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp;RegularExpression(pattern: pattern, options: [ .dotMatchesLineSeparators ])</span></span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp;&nbsp;</span><span style="font-variant-ligatures: no-common-ligatures; color: #78492a" class="">#endif</span></div></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #78492a" class=""><span style="font-family: Helvetica; font-size: 12px;" class=""><br class=""></span></span></div><div style="margin: 0px; line-height: normal;" class="">Additionally, we can consider supporting the == operator,&nbsp;so that checking only the version with inconsistent naming is sufficient:</div><div style="margin: 0px; line-height: normal;" class=""><br class=""></div><div style="margin: 0px; line-height: normal;" class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(120, 73, 42);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; #if</span><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp;!</span><span style="font-variant-ligatures: no-common-ligatures" class="">os</span><span style="font-variant-ligatures: no-common-ligatures;" class="">(</span><span style="font-variant-ligatures: no-common-ligatures" class="">macOS</span><span style="font-variant-ligatures: no-common-ligatures;" class="">) &amp;&amp; </span><span style="font-variant-ligatures: no-common-ligatures" class="">swift</span><span style="font-variant-ligatures: no-common-ligatures;" class="">(==</span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">3.0</span><span style="font-variant-ligatures: no-common-ligatures;" class="">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">0</span><span style="font-variant-ligatures: no-common-ligatures;" class="">)</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">let</span><span style="font-variant-ligatures: no-common-ligatures" class=""> regex = </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">try</span><span style="font-variant-ligatures: no-common-ligatures" class=""> RegularExpression(pattern: pattern, options: [ .dotMatchesLineSeparators ])</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #78492a" class="">#else</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">let</span><span style="font-variant-ligatures: no-common-ligatures" class=""> regex = </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">try</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">NSRegularExpression</span><span style="font-variant-ligatures: no-common-ligatures" class="">(pattern: pattern, options: [ .</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">dotMatchesLineSeparators</span><span style="font-variant-ligatures: no-common-ligatures" class=""> ])</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #78492a" class="">#endif</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><b style="font-family: Helvetica; font-size: 12px;" class="">Impact on existing code:</b></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><br class=""></div><div style="margin: 0px; line-height: normal;" class="">`#if swift(&gt;=X.X.X)` and `#if swift(==X.X.X)` are purely additive.</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #78492a" class=""><br class=""></span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #78492a" class=""><span style="font-family: Helvetica; font-size: 12px;" class="">-Richard</span></span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #78492a" class=""><span style="font-family: Helvetica; font-size: 12px;" class=""><br class=""></span></span></div></div></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></body></html>