<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=""><div class="">Taking the long form approach:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Monaco;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">enum</span><span style="font-variant-ligatures: no-common-ligatures" class=""> Things:</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">String</span><span style="font-variant-ligatures: no-common-ligatures" class=""> {</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Monaco;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">@available</span><span style="font-variant-ligatures: no-common-ligatures" class=""> (iOS </span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">9.0</span><span style="font-variant-ligatures: no-common-ligatures" class="">, tvOS </span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">9.0</span><span style="font-variant-ligatures: no-common-ligatures" class="">, watchOS </span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">2.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: Monaco;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">@available</span><span style="font-variant-ligatures: no-common-ligatures" class=""> (OSX, unavailable, message=</span><span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">"Not available on OS X."</span><span style="font-variant-ligatures: no-common-ligatures" class="">)</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Monaco; color: rgb(209, 47, 27);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">case</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> MobileThing = </span><span style="font-variant-ligatures: no-common-ligatures" class="">"com.example.mobile"</span></div><p style="margin: 0px; font-size: 11px; line-height: normal; font-family: Monaco; min-height: 15px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Monaco;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">@available</span><span style="font-variant-ligatures: no-common-ligatures" class=""> (iOS, unavailable, message=</span><span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">"Not available on iOS."</span><span style="font-variant-ligatures: no-common-ligatures" class="">)</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Monaco;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">@available</span><span style="font-variant-ligatures: no-common-ligatures" class=""> (tvOS, unavailable, message=</span><span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">"Not available on tvOS."</span><span style="font-variant-ligatures: no-common-ligatures" class="">)</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Monaco;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">@available</span><span style="font-variant-ligatures: no-common-ligatures" class=""> (watchOS, unavailable, message=</span><span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">"Not available on watchOS."</span><span style="font-variant-ligatures: no-common-ligatures" class="">)</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Monaco;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">@available</span><span style="font-variant-ligatures: no-common-ligatures" class=""> (OSX </span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">10.11</span><span style="font-variant-ligatures: no-common-ligatures" class="">, *)</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Monaco; color: rgb(209, 47, 27);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">case</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> DesktopThing = </span><span style="font-variant-ligatures: no-common-ligatures" class="">"com.example.desktop"</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Monaco;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">}</span></div></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Monaco;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div style="margin: 0px; font-size: 11px; line-height: normal;" class="">This yields the expected result in a tvOS app:</div><div style="margin: 0px; font-size: 11px; line-height: normal;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal;" class=""><div style="margin: 0px; line-height: normal; font-family: Monaco;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span><span style="font-variant-ligatures: no-common-ligatures" class=""> that(thing:</span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">Things</span><span style="font-variant-ligatures: no-common-ligatures" class="">) -> () {</span></div><div style="margin: 0px; line-height: normal; font-family: Monaco;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">print</span><span style="font-variant-ligatures: no-common-ligatures" class="">(thing)</span></div><div style="margin: 0px; line-height: normal; font-family: Monaco;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">}</span></div><div style="margin: 0px; line-height: normal; font-family: Monaco;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">that</span>(.DesktopThing) // 'DesktopThing' is unavailable. Not available on tvOS.</span></div><div style="margin: 0px; line-height: normal; font-family: Monaco;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div style="margin: 0px; line-height: normal;" class="">A limited availability attribute does have some merit, perhaps using a different keyword (so you know you are choosing it), for example:</div><div style="margin: 0px; line-height: normal;" class=""><br class=""></div><div style="margin: 0px; line-height: normal;" class=""><div style="margin: 0px; line-height: normal; font-family: Monaco;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class=""> <span class="Apple-tab-span" style="white-space:pre">        </span>@restricted</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> (OSX </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);" class="">10.11</span><span style="font-variant-ligatures: no-common-ligatures;" class="">, *, </span><span style="font-variant-ligatures: no-common-ligatures;" class="">message=</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(209, 47, 27);" class="">"Only available on OS X."</span>)</div><div style="margin: 0px; line-height: normal; font-family: Monaco; color: rgb(209, 47, 27);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);" class=""> <span class="Apple-tab-span" style="white-space:pre">        </span></span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class="">case</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);" class=""> DesktopThing = </span><span style="font-variant-ligatures: no-common-ligatures;" class="">"com.example.desktop"</span></div></div><div style="margin: 0px; line-height: normal;" class=""><span class="Apple-tab-span" style="white-space:pre">        </span></div><div style="margin: 0px; line-height: normal;" class=""><div style="margin: 0px; line-height: normal; font-family: Monaco;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>func</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> that(thing:</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);" class="">Things</span><span style="font-variant-ligatures: no-common-ligatures;" class="">) -> () {</span></div><div style="margin: 0px; line-height: normal; font-family: Monaco;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> <span class="Apple-tab-span" style="white-space:pre">        </span></span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(61, 29, 129);" class="">print</span><span style="font-variant-ligatures: no-common-ligatures;" class="">(thing)</span></div><div style="margin: 0px; line-height: normal; font-family: Monaco;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>}</span></div><div style="margin: 0px; line-height: normal; font-family: Monaco;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: rgb(49, 89, 93);" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>that</span>(.DesktopThing) // 'DesktopThing' is unavailable. Only available on OS X.</span></div></div><div style="margin: 0px; line-height: normal;" class=""><br class=""></div><div style="margin: 0px; line-height: normal;" class=""><br class=""></div><div style="margin: 0px; line-height: normal;" class="">...but this is outside the scope of the original topic.</div><div style="margin: 0px; line-height: normal;" class=""><br class=""></div><div style="margin: 0px; line-height: normal;" class="">Stuart</div></div><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">On 26 May 2016, at 11:23, Jordan Rose <<a href="mailto:jordan_rose@apple.com" class="">jordan_rose@apple.com</a>> 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=""><div class="">This was deliberate, and came from the pain of bringing up tvOS (and watchOS). Clang actually had a hack to treat “available on iOS” as “available on tvOS” for a while because of this. When you port something to a new platform, presumably everything that’s been introduced so far should be available from the start.</div><div class=""><br class=""></div><div class="">If we introduced a limited availability attribute, I think we’d want to make it <i class="">more</i> verbose than the normal one, so that you know you’re choosing it.</div><div class=""><br class=""></div><div class="">Jordan</div><div class=""><br class=""></div><br class=""><div class=""><blockquote type="cite" class=""><div class="">On May 25, 2016, at 20:18, Jacob Bandes-Storch <<a href="mailto:jtbandes@gmail.com" class="">jtbandes@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Was this an intentional choice, or is it just a temporary limitation? Would a proposal to allow something like "@available(OS X 10.11)" be welcomed?<div class="gmail_extra"><div class=""><div class="gmail_signature"><div dir="ltr" class=""><div class=""><br class=""></div></div></div></div>
<br class=""><div class="gmail_quote">On Wed, May 25, 2016 at 8:17 PM, Jordan Rose via swift-evolution <span dir="ltr" class=""><<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class="">The “*” in @available means “all other platforms”. If you want to mark something <i class="">unavailable</i> on a particular platform, you’ll have to use the long form of the @available attribute. There’s currently no way to mark something “only available on these platforms”.</div><div class=""><br class=""></div><div class="">Jordan</div><br class=""><div class=""><blockquote type="cite" class=""><div class=""><div class="h5"><div class="">On May 25, 2016, at 18:48, Stuart Breckenridge via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>> wrote:</div><br class=""></div></div><div class=""><div class=""><div class="h5"><div style="word-wrap:break-word" class="">Presently, you can mark enum cases as <font face="Menlo" class="">@available</font> but it has no impact. Take the following example:<div class=""><br class=""></div><div class=""><font face="Menlo" class="">enum Things:String {</font></div><div class=""><font face="Menlo" class=""><span style="white-space:pre-wrap" class="">        </span>@available (iOS 9.3, *) case MobileThing = "com.example.mobilething"</font></div><div class=""><font face="Menlo" class=""><span style="white-space:pre-wrap" class="">        </span>@available (OSX 10.11, *) case DesktopThing = "com.example.desktopthing"</font></div><div class=""><font face="Menlo" class="">}</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class="">Despite the above compiling, the following code will run iOS with no warnings:</div><div class=""><br class=""></div><div class=""><font face="Menlo" class="">func takesA(thing:Things) {</font></div><div class=""><font face="Menlo" class=""><span style="white-space:pre-wrap" class="">        </span>print(thing)</font></div><div class=""><font face="Menlo" class="">}</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class="">takesA(.DesktopThing)</font></div><div class=""><br class=""></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class="">Are there enough compelling use-cases for @available on enum cases to be considered? At the very least, if <font face="Menlo" class="">@available</font> doesn't do anything on cases, it shouldn't be permitted.</div></div></div></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div></blockquote></div><br class=""></div><br class="">_______________________________________________<br class="">
swift-evolution mailing list<br class="">
<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="">
<br class=""></blockquote></div><br class=""></div></div>
</div></blockquote></div><br class=""></div></div></blockquote></div><br class=""></body></html>