What&#39;s the intended most common use case for this? The one that I can think of that will show up very often is &quot;declare this function only if Swift version is &gt;= X because it relies on some new feature&quot;<br>In that case, would it make sense for consistency to also be able to mark a function (or type) as &quot;only available on Swift &gt;= X&quot;, like you do with ios releases? (ie @available(swift, 2.2))<br><div class="gmail_quote"><div dir="ltr">On Sat, Dec 19, 2015 at 1:28 AM David Farler via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
&gt; On Dec 18, 2015, at 3:34 PM, Douglas Gregor via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br>
&gt;<br>
&gt;&gt;<br>
&gt;&gt; On Dec 18, 2015, at 12:29 PM, Chris Lattner via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; On Dec 18, 2015, at 12:25 PM, Radosław Pietruszewski via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Sounds like it could be super useful for libraries!<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; How about we drop the quote marks, though? If we have `os(iOS)` and `#available(iOS 9, *)` (in other context), why not `swift(2.2)`?<br>
&gt;&gt;<br>
&gt;&gt; I agree with Radek.<br>
&gt;&gt;<br>
&gt;&gt; The argument to use a string is if we wanted to support subversions, e.g. like “#if swift(2.2.1)”.  This requires the parameter to be a string, because 2.2.1 isn’t a valid floating point literal - the lexer will be displeased.<br>
&gt;&gt;<br>
&gt;&gt; However, I don’t think we *want* the feature to be able to do that.  The most important use case for this feature is to handle syntactic differences across swift versions, and we don’t want those in sub-versions.  Given that, it seems better to keep the syntax clean and simple.<br>
&gt;<br>
&gt; This feature LGTM, and I also prefer that we drop the quotes. Two levels of version number should be sufficient.<br>
&gt;<br>
&gt;       - Doug<br>
&gt;<br>
&gt;  _______________________________________________<br>
&gt; swift-evolution mailing list<br>
&gt; <a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
&gt; <a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
<br>
Chris brought something up that a few of us had discussed in the past: the ambiguity of what the operation does. It&#39;s implicitly &quot;current version &gt;= specified version&quot;, but I wonder how many people will want to compare otherwise or will assume the comparison is &#39;==&#39;.<br>
<br>
We can fix this in two ways:<br>
<br>
Option 1: #if swift(&lt;x.y)<br>
<br>
or<br>
<br>
Option 2: #if swift &gt; x.y<br>
<br>
I thought I preferred Option 1 but I think Option 2 reads more how you would expect and somewhat reflects the regular syntax of the language, FWIW. I sketched out both implementations and they&#39;re about the same in complexity, so I would suggest Option 2, unless it&#39;s a strong goal to keep special sauce in build configurations as &quot;function calls&quot;.<br>
<br>
Maybe not all of the comparison operators are necessary, but in general this gives some flexibility to arrange checks (newer code at the top or at the bottom) and actually describes what comparison is happening.<br>
<br>
David<br>
_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</blockquote></div><div dir="ltr">-- <br></div>Javier Soto