<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>Named platforms always take precedence over the *, in essence. &nbsp;</div><div id="AppleMailSignature"><br>Sent from my iPad</div><div><br>On 27 May 2016, at 15:44, Xiaodi Wu &lt;<a href="mailto:xiaodi.wu@gmail.com">xiaodi.wu@gmail.com</a>&gt; wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr">I dislike `@restricted` for several reasons. First of all,&nbsp;but for a desire for brevity, @available and @restricted would do the same thing. I don't think that's justifiable or intuitive. Second, I don't think it's at all readable: are the named platforms restricted from using the function, or is the function restricted to those platforms? The name could equally mean either one.<div><br><div>Brent's suggestion is perfectly cogent:</div><div><br></div><div>```</div><div><span style="font-size:13px">@available(OSX, introduced: 10.8)</span><br style="font-size:13px"><span style="font-size:13px">@available(iOS, introduced: 9.4)</span><br style="font-size:13px"><span style="font-size:13px">@available(*, unavailable)</span><br></div><div>```</div><div><div><br></div><div>I would even go so far as to say that neither `only` nor `@restricted` are needed. By that I mean, if you type this:</div><div><br></div><div>```</div><div>@available(OSX 10.8, iOS 9.4)</div><div>```</div><div><br></div><div>That's not valid. You'll be prompted to write this:</div><div><br></div><div>```</div><div>@available(OSX 10.8, iOS 9.4, *)<br></div><div>```</div><div><br></div><div>I'd propose to give the user the additional option of writing this:</div><div><br></div><div>```</div><div>@available(OSX 10.8, iOS 9.4)<br></div><div>@available(*, unavailable)</div><div>```</div><div><br></div><div>In other words, the rule for using the @available shorthand would be that you must mention * somewhere; it can be at the end of the shorthand, or it can be on its own line. This would maintain the desired verbosity so that the latter option is not as accessible as the preferred one, but it avoids the recitation of all unavailable platforms currently required.</div><div><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, May 26, 2016 at 11:59 PM, Stuart Breckenridge <span dir="ltr">&lt;<a href="mailto:stuart.breckenridge@icloud.com" target="_blank">stuart.breckenridge@icloud.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div style="word-wrap:break-word"><div>Are we back in a position where a different attribute (back to <font face="Menlo">@restricted</font><font style="color:rgb(255,64,19)"> </font>or similar keyword) would clear up the readability concerns?</div><div><br></div><div>The current equivalent in <font face="Menlo">@available</font> terms:</div><div><br></div><div>Short form:</div><div><font face="Menlo"><span style="white-space:pre-wrap">        </span>@available(OSX 10.8, iOS 8.0, *)</font></div><div><font face="Menlo"><span style="white-space:pre-wrap">        </span>@available(tvOS, unavailable)</font></div><div><font face="Menlo"><span style="white-space:pre-wrap">        </span>@available(watchOS, unavailable)</font></div><div><br></div><div>Long form:</div><div><font face="Menlo"><span style="white-space:pre-wrap">        </span>@available(OSX, introduced: 10.8,&nbsp;</font><span style="font-family:Menlo">deprecated: 10.10</span><span style="font-family:Menlo">)</span></div><div><font face="Menlo"><span style="white-space:pre-wrap">        </span>@available(iOS, introduced: 8.0,&nbsp;</font><span style="font-family:Menlo">deprecated: 8.4, obsoleted: 9.0</span><span style="font-family:Menlo">)</span></div><div><font face="Menlo"><span style="white-space:pre-wrap">        </span>@available(tvOS, unavailable)</font></div><div><font face="Menlo"><span style="white-space:pre-wrap">        </span>@available(watchOS, unavailable)</font></div><div><span style="color:rgb(255,64,19)"><br></span></div><div><div>Short form replacement:</div><div><font face="Menlo"><span style="white-space:pre-wrap">        </span>@restricted(OSX 10.8, iOS 8.0) // Restricted to OSX, iOS from 10.8 and 8.0, respectively.</font></div><div><br></div><div>Long form replacement:</div><div><font face="Menlo"><span style="white-space:pre-wrap">        </span>@restricted(OSX, introduced: 10.8, deprecated: 10.10)</font></div><div><font face="Menlo">&nbsp; &nbsp; &nbsp; &nbsp; @restricted(iOS, introduced: 8.0, deprecated: 8.4, obsoleted: 9.0)</font></div></div><div><font face="Menlo"><br></font></div><div><font face="Menlo"><br></font></div><div>I would amend the draft proposal:&nbsp;<font face="Menlo">*</font>&nbsp;would not be permitted with&nbsp;<span style="font-family:Menlo">@restricted</span>. The rationale being that if you are restricting to <i>everything, </i>or marking everything as unavailable,&nbsp;<font face="Menlo">@available(*,unavailable)&nbsp;</font>is a better candidate.</div><span class=""><font color="#888888"><div><font color="#ff4013" face="Menlo"><br></font></div><div><font face="Menlo" color="#3a88fe">Stuart</font></div></font></span><div><div class="h5"><br><div><blockquote type="cite"><div>On 27 May 2016, at 11:06, Brent Royal-Gordon &lt;<a href="mailto:brent@architechies.com" target="_blank">brent@architechies.com</a>&gt; wrote:</div><br><div><div><blockquote type="cite">What I'm saying here is that even if you accept that the asterisk means all platforms, it does not follow that another argument in the same place should refer to the platform names *listed in the attribute*. That's not at all precedented in the meaning of the asterisk.<br></blockquote><br>The problem is, the most natural way to express this is absolutely this:<br><br><span style="white-space:pre-wrap">        </span>@available(OSX 10.8, iOS 8, *)<span style="white-space:pre-wrap">        </span>// includes other platforms<br><span style="white-space:pre-wrap">        </span>@available(OSX 10.8, iOS 8)<span style="white-space:pre-wrap">        </span><span style="white-space:pre-wrap">        </span>// excludes other platforms<br><br>But we don't want to do that because we want people to use `*` by default. You could maybe do something like:<br><br><span style="white-space:pre-wrap">        </span>@available(OSX 10.8, iOS 8, * unavailable)<br><br>But I think that reads very strangely, and it doesn't seem consistent with the other parameters. (Well, unless you can write `OSX unavailable`, which would actually be kind of convenient, but would still read oddly in a declaration named `@available`.) Hence my suggestion:<br><br><span style="white-space:pre-wrap">        </span>@available(OSX 10.8, iOS 8, only)<br><br>Which is meant to be read as "Available in OS X (starting in 10.8) and iOS (starting in 8) only".<br><br>(It would be nice if the syntax actually said "OSX 10.8+", and maybe even permitted a range for things that have been retired, like `OSX 10.8..&lt;10.10`. The main problem I see with supporting a range is that the most natural interpretation of the right end is an unavailability version, but the most useful thing to have there would be a deprecation version.)<br><br><blockquote type="cite">Furthermore, the asterisk is put after a list of things *only in the shorthand syntax*, whereas you are proposing that "only" should be usable in the full syntax as well, in a position where the asterisk is not allowed. It is something else entirely to say that a feature is available in OSX version so-and-so only and then to say it's available in iOS version so-and-so only, when in fact you mean that it's not available *on other platforms*.<br></blockquote><br>Yes, that was not what I intended when I suggested `only`.<br><br><blockquote type="cite">What makes more sense to me would be allowing (if it isn't already allowed) `@available(*, unavailable)` to follow a previous @available declaration in order to mean that the feature is unavailable on all platforms not otherwise specified.<br></blockquote><br>Yes, something like this makes sense to me too. Basically, I think the shorthand form should look like:<br><br><span style="white-space:pre-wrap">        </span>@available(OSX 10.8, iOS 9.4, only)<br><br>And the longhand form like:<br><br><span style="white-space:pre-wrap">        </span>@available(OSX, introduced: 10.8)<br><span style="white-space:pre-wrap">        </span>@available(iOS, introduced: 9.4)<br><span style="white-space:pre-wrap">        </span>@available(*, unavailable)<br><br>(The switch from `introduced=` to `introduced:` is an already-approved Swift 3 change.)<br><br>Perhaps you should even be required to say either `@available(*)` or `@available(*, unavailable)` if there are longhand `@available` attributes on the type. <br><br>-- <br>Brent Royal-Gordon<br>Architechies<br><br></div></div></blockquote></div><br></div></div></div></blockquote></div><br></div></div></div></div></div>
</div></blockquote></body></html>