<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="">I’m not sure about this, as restricting anything by OS generally makes me uneasy; where possible we should always try to restrict code by availability and version of modules, as these will indicate the actual features that a platform should support. Part of the problem is that we can’t guarantee what new OSes will be supported in future, in your example you’ve already only covered Apple OSes, but Linux support is on its way, and Windows support may come (Visual Studio may already support it).</div><div class=""><br class=""></div><div class="">I mean, it’s no more or less prone to issues than @available I suppose, but I’m not a fan of limiting features and support in this way to begin with.</div><br class=""><div><blockquote type="cite" class=""><div class="">On 26 May 2016, at 14:25, Stuart Breckenridge via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><h1 id="addanrestricteddeclarationattribute" style="text-align: left; box-sizing: border-box; font-size: calc(1.2777777777777777rem); margin: 0px 0px calc(3.3333333333333335rem); line-height: calc(1.3043478260869565); text-transform: uppercase; letter-spacing: 0.5px; color: rgb(26, 26, 26); font-family: NittiGrotesk, Keyboard, sans-serif;" class="">ADD AN @RESTRICTED DECLARATION ATTRIBUTE</h1><ul style="box-sizing: border-box; padding-left: 1.5rem; margin: calc(1.6666666666666667rem) auto 0px; list-style: none; color: rgb(26, 26, 26); font-family: NittiGrotesk, Keyboard, sans-serif; font-size: 14px;" class=""><li style="box-sizing: border-box;" class="">Proposal: SE-NNNN</li><li style="box-sizing: border-box;" class="">Author: Stuart Breckenridge</li><li style="box-sizing: border-box;" class="">Status: DRAFT</li><li style="box-sizing: border-box;" class="">Review Manager: TBD</li></ul><h2 id="introduction" style="text-align: left; box-sizing: border-box; margin-top: calc(3.3333333333333335rem); margin-bottom: calc(1.6666666666666667rem); font-size: calc(1.1666666666666667rem); line-height: calc(1.4285714285714286); color: rgb(26, 26, 26); font-family: NittiGrotesk, Keyboard, sans-serif;" class="">Introduction</h2><div style="box-sizing: border-box; margin: calc(1.6666666666666667rem) auto 0px; color: rgb(26, 26, 26); font-family: NittiGrotesk, Keyboard, sans-serif; font-size: 14px;" class="">Adapted from the Swift 2.2 Programming Guide:</div><blockquote style="box-sizing: border-box; margin: calc(1.6666666666666667rem) calc(-0.8888888888888888rem) 0px; padding-left: calc(2.2222222222222223rem); padding-right: calc(2.2222222222222223rem); font-style: italic; color: rgb(26, 26, 26); font-family: NittiGrotesk, Keyboard, sans-serif; font-size: 14px;" class=""><div style="box-sizing: border-box; margin: calc(1.6666666666666667rem) auto 0px;" class="">The <code style="box-sizing: border-box; font-family: NittiPro, Keyboard, monospace; font-size: calc(0.8333333333333334em); border-top-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 2px; white-space: pre-wrap; background-color: rgb(230, 230, 230); padding: 0.1667em 0.3334em 0.25em;" class="">@available</code> attribute indicates a declaration’s life cycle relative to certain platforms and operating systems. Today’s functionality allows you to add multiple <code style="box-sizing: border-box; font-family: NittiPro, Keyboard, monospace; font-size: calc(0.8333333333333334em); border-top-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 2px; white-space: pre-wrap; background-color: rgb(230, 230, 230); padding: 0.1667em 0.3334em 0.25em;" class="">@available</code> attributes on a declaration to specify its availability on different platforms.</div></blockquote><div style="box-sizing: border-box; margin: calc(1.6666666666666667rem) auto 0px; color: rgb(26, 26, 26); font-family: NittiGrotesk, Keyboard, sans-serif; font-size: 14px;" class="">In a related Swift Evolution discussion examining the <code style="box-sizing: border-box; font-family: NittiPro, Keyboard, monospace; font-size: calc(0.8333333333333334em); border-top-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 2px; white-space: pre-wrap; background-color: rgb(230, 230, 230); padding: 0.1667em 0.3334em 0.25em;" class="">@available</code> attribute, it was confirmed that there is currently no way to limit availability to specific platform without using the long form approach.</div><h2 id="motivation" style="text-align: left; box-sizing: border-box; margin-top: calc(3.3333333333333335rem); margin-bottom: calc(1.6666666666666667rem); font-size: calc(1.1666666666666667rem); line-height: calc(1.4285714285714286); color: rgb(26, 26, 26); font-family: NittiGrotesk, Keyboard, sans-serif;" class="">Motivation</h2><div style="box-sizing: border-box; margin: calc(1.6666666666666667rem) auto 0px; color: rgb(26, 26, 26); font-family: NittiGrotesk, Keyboard, sans-serif; font-size: 14px;" class="">When a declaration is only available on a certain platform, it requires multiple <code style="box-sizing: border-box; font-family: NittiPro, Keyboard, monospace; font-size: calc(0.8333333333333334em); border-top-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 2px; white-space: pre-wrap; background-color: rgb(230, 230, 230); padding: 0.1667em 0.3334em 0.25em;" class="">@available</code> attributes to restrict its availability to that platform. Consider the following example using <code style="box-sizing: border-box; font-family: NittiPro, Keyboard, monospace; font-size: calc(0.8333333333333334em); border-top-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 2px; white-space: pre-wrap; background-color: rgb(230, 230, 230); padding: 0.1667em 0.3334em 0.25em;" class="">SLServiceType</code> like constants:</div><pre style="box-sizing: border-box; overflow: hidden; font-family: monospace, monospace; font-size: 14px; border-top-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 2px; white-space: pre-wrap; background-color: rgb(230, 230, 230); padding: 1rem; margin: calc(1.6666666666666667rem) auto 0px; color: rgb(26, 26, 26);" class=""><code style="box-sizing: border-box; font-family: NittiPro, Keyboard, monospace; font-size: calc(0.8333333333333334em); border-top-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 2px; padding: 0px;" class="">@available(iOS, unavailable)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
@available(OSX 10.8, *)
case LinkedIn = "com.apple.social.linkedin"
</code></pre><div style="box-sizing: border-box; margin: calc(1.6666666666666667rem) auto 0px; color: rgb(26, 26, 26); font-family: NittiGrotesk, Keyboard, sans-serif; font-size: 14px;" class="">The compiler will only use an <code style="box-sizing: border-box; font-family: NittiPro, Keyboard, monospace; font-size: calc(0.8333333333333334em); border-top-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 2px; white-space: pre-wrap; background-color: rgb(230, 230, 230); padding: 0.1667em 0.3334em 0.25em;" class="">@available</code> attribute when the attribute specifies a platform that matches the current target platform. The implication being that if the target platform isn’t specified, then the attribute defaults to available.</div><div style="box-sizing: border-box; margin: calc(1.6666666666666667rem) auto 0px; color: rgb(26, 26, 26); font-family: NittiGrotesk, Keyboard, sans-serif; font-size: 14px;" class="">Thus, while it is clear that the above is restricting availability to OS X 10.8 and later, it is verbose and <span style="box-sizing: border-box; font-weight: 600;" class="">can be simplified</span>.</div><h2 id="proposal" style="text-align: left; box-sizing: border-box; margin-top: calc(3.3333333333333335rem); margin-bottom: calc(1.6666666666666667rem); font-size: calc(1.1666666666666667rem); line-height: calc(1.4285714285714286); color: rgb(26, 26, 26); font-family: NittiGrotesk, Keyboard, sans-serif;" class="">Proposal</h2><div style="box-sizing: border-box; margin: calc(1.6666666666666667rem) auto 0px; color: rgb(26, 26, 26); font-family: NittiGrotesk, Keyboard, sans-serif; font-size: 14px;" class="">Implement an <code style="box-sizing: border-box; font-family: NittiPro, Keyboard, monospace; font-size: calc(0.8333333333333334em); border-top-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 2px; white-space: pre-wrap; background-color: rgb(230, 230, 230); padding: 0.1667em 0.3334em 0.25em;" class="">@restricted</code> attribute which is the inverse of <code style="box-sizing: border-box; font-family: NittiPro, Keyboard, monospace; font-size: calc(0.8333333333333334em); border-top-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 2px; white-space: pre-wrap; background-color: rgb(230, 230, 230); padding: 0.1667em 0.3334em 0.25em;" class="">@available</code>. The effect would be that the compiler would use <code style="box-sizing: border-box; font-family: NittiPro, Keyboard, monospace; font-size: calc(0.8333333333333334em); border-top-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 2px; white-space: pre-wrap; background-color: rgb(230, 230, 230); padding: 0.1667em 0.3334em 0.25em;" class="">@restricted</code> to limit the declaration to be available on the platform(s) specified in the attribute. Similar to <code style="box-sizing: border-box; font-family: NittiPro, Keyboard, monospace; font-size: calc(0.8333333333333334em); border-top-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 2px; white-space: pre-wrap; background-color: rgb(230, 230, 230); padding: 0.1667em 0.3334em 0.25em;" class="">@available</code>, multiple <code style="box-sizing: border-box; font-family: NittiPro, Keyboard, monospace; font-size: calc(0.8333333333333334em); border-top-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 2px; white-space: pre-wrap; background-color: rgb(230, 230, 230); padding: 0.1667em 0.3334em 0.25em;" class="">@restricted</code> attributes can be added to a declaration. </div><div style="box-sizing: border-box; margin: calc(1.6666666666666667rem) auto 0px; color: rgb(26, 26, 26); font-family: NittiGrotesk, Keyboard, sans-serif; font-size: 14px;" class="">Therefore, where <code style="box-sizing: border-box; font-family: NittiPro, Keyboard, monospace; font-size: calc(0.8333333333333334em); border-top-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 2px; white-space: pre-wrap; background-color: rgb(230, 230, 230); padding: 0.1667em 0.3334em 0.25em;" class="">@restricted</code> attribute(s) are present and target platform <em style="box-sizing: border-box;" class="">is not</em> specified, the declaration is not available on the unspecified target platform. In addition, where a <code style="box-sizing: border-box; font-family: NittiPro, Keyboard, monospace; font-size: calc(0.8333333333333334em); border-top-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 2px; white-space: pre-wrap; background-color: rgb(230, 230, 230); padding: 0.1667em 0.3334em 0.25em;" class="">@restricted</code> attribute has been applied to a declaration, it should not be commingled with <code style="box-sizing: border-box; font-family: NittiPro, Keyboard, monospace; font-size: calc(0.8333333333333334em); border-top-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 2px; white-space: pre-wrap; background-color: rgb(230, 230, 230); padding: 0.1667em 0.3334em 0.25em;" class="">@available</code> on the same declaration (it would lead to intense confusion).</div><h2 id="design" style="text-align: left; box-sizing: border-box; margin-top: calc(3.3333333333333335rem); margin-bottom: calc(1.6666666666666667rem); font-size: calc(1.1666666666666667rem); line-height: calc(1.4285714285714286); color: rgb(26, 26, 26); font-family: NittiGrotesk, Keyboard, sans-serif;" class="">Design</h2><div style="box-sizing: border-box; margin: calc(1.6666666666666667rem) auto 0px; color: rgb(26, 26, 26); font-family: NittiGrotesk, Keyboard, sans-serif; font-size: 14px;" class="">From a syntax perspective, it would follow <code style="box-sizing: border-box; font-family: NittiPro, Keyboard, monospace; font-size: calc(0.8333333333333334em); border-top-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 2px; white-space: pre-wrap; background-color: rgb(230, 230, 230); padding: 0.1667em 0.3334em 0.25em;" class="">@available</code>:</div><div style="box-sizing: border-box; margin: calc(1.6666666666666667rem) auto 0px; color: rgb(26, 26, 26); font-family: NittiGrotesk, Keyboard, sans-serif; font-size: 14px;" class="">@restricted(<code style="box-sizing: border-box; font-family: NittiPro, Keyboard, monospace; font-size: calc(0.8333333333333334em); border-top-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 2px; white-space: pre-wrap; background-color: rgb(230, 230, 230); padding: 0.1667em 0.3334em 0.25em;" class="">platform name</code> <code style="box-sizing: border-box; font-family: NittiPro, Keyboard, monospace; font-size: calc(0.8333333333333334em); border-top-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 2px; white-space: pre-wrap; background-color: rgb(230, 230, 230); padding: 0.1667em 0.3334em 0.25em;" class="">version number</code>, *)</div><div style="box-sizing: border-box; margin: calc(1.6666666666666667rem) auto 0px; color: rgb(26, 26, 26); font-family: NittiGrotesk, Keyboard, sans-serif; font-size: 14px;" class="">or</div><div style="box-sizing: border-box; margin: calc(1.6666666666666667rem) auto 0px; color: rgb(26, 26, 26); font-family: NittiGrotesk, Keyboard, sans-serif; font-size: 14px;" class="">@restricted(<code style="box-sizing: border-box; font-family: NittiPro, Keyboard, monospace; font-size: calc(0.8333333333333334em); border-top-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 2px; white-space: pre-wrap; background-color: rgb(230, 230, 230); padding: 0.1667em 0.3334em 0.25em;" class="">platform name</code>, <code style="box-sizing: border-box; font-family: NittiPro, Keyboard, monospace; font-size: calc(0.8333333333333334em); border-top-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 2px; white-space: pre-wrap; background-color: rgb(230, 230, 230); padding: 0.1667em 0.3334em 0.25em;" class="">introduced=version number</code>)</div><div style="box-sizing: border-box; margin: calc(1.6666666666666667rem) auto 0px; color: rgb(26, 26, 26); font-family: NittiGrotesk, Keyboard, sans-serif; font-size: 14px;" class="">Similarly, all <code style="box-sizing: border-box; font-family: NittiPro, Keyboard, monospace; font-size: calc(0.8333333333333334em); border-top-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 2px; white-space: pre-wrap; background-color: rgb(230, 230, 230); padding: 0.1667em 0.3334em 0.25em;" class="">@available</code> arguments would be available to <code style="box-sizing: border-box; font-family: NittiPro, Keyboard, monospace; font-size: calc(0.8333333333333334em); border-top-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 2px; white-space: pre-wrap; background-color: rgb(230, 230, 230); padding: 0.1667em 0.3334em 0.25em;" class="">@restricted</code>. </div><h3 id="examples" style="text-align: left; box-sizing: border-box; margin-top: calc(1.6666666666666667rem); font-size: 1rem; margin-bottom: 0px; line-height: calc(1.6666666666666667); color: rgb(26, 26, 26); font-family: NittiGrotesk, Keyboard, sans-serif;" class="">Examples</h3><div class=""><br class=""></div><div style="box-sizing: border-box; margin: 0px auto; color: rgb(26, 26, 26); font-family: NittiGrotesk, Keyboard, sans-serif; font-size: 14px;" class="">Using the previous example, instead of using <code style="box-sizing: border-box; font-family: NittiPro, Keyboard, monospace; font-size: calc(0.8333333333333334em); border-top-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 2px; white-space: pre-wrap; background-color: rgb(230, 230, 230); padding: 0.1667em 0.3334em 0.25em;" class="">@available</code> to specify unavailability, we use <code style="box-sizing: border-box; font-family: NittiPro, Keyboard, monospace; font-size: calc(0.8333333333333334em); border-top-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 2px; white-space: pre-wrap; background-color: rgb(230, 230, 230); padding: 0.1667em 0.3334em 0.25em;" class="">@restricted</code> to scope the declarations availability:</div><div style="box-sizing: border-box; margin: calc(1.6666666666666667rem) auto 0px; color: rgb(26, 26, 26); font-family: NittiGrotesk, Keyboard, sans-serif; font-size: 14px;" class=""><em style="box-sizing: border-box;" class="">Single Platform Restriction</em></div><pre style="box-sizing: border-box; overflow: hidden; font-family: monospace, monospace; font-size: 14px; border-top-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 2px; white-space: pre-wrap; background-color: rgb(230, 230, 230); padding: 1rem; margin: calc(1.6666666666666667rem) auto 0px; color: rgb(26, 26, 26);" class=""><code style="box-sizing: border-box; font-family: NittiPro, Keyboard, monospace; font-size: calc(0.8333333333333334em); border-top-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 2px; padding: 0px;" class="">@restricted(OSX 10.8, *)
case LinkedIn = "com.apple.social.linkedin"
</code></pre><div style="box-sizing: border-box; margin: calc(1.6666666666666667rem) auto 0px; color: rgb(26, 26, 26); font-family: NittiGrotesk, Keyboard, sans-serif; font-size: 14px;" class="">Effect: only available on OS X 10.8 or newer.</div><div style="box-sizing: border-box; margin: calc(1.6666666666666667rem) auto 0px; color: rgb(26, 26, 26); font-family: NittiGrotesk, Keyboard, sans-serif; font-size: 14px;" class=""><em style="box-sizing: border-box;" class="">Multiple Platform Restriction</em></div><pre style="box-sizing: border-box; overflow: hidden; font-family: monospace, monospace; font-size: 14px; border-top-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 2px; white-space: pre-wrap; background-color: rgb(230, 230, 230); padding: 1rem; margin: calc(1.6666666666666667rem) auto 0px; color: rgb(26, 26, 26);" class=""><code style="box-sizing: border-box; font-family: NittiPro, Keyboard, monospace; font-size: calc(0.8333333333333334em); border-top-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 2px; padding: 0px;" class="">@restricted(OSX 10.8, iOS 9.4, *)
case LinkedIn = "com.apple.social.linkedin"
</code></pre><div style="box-sizing: border-box; margin: calc(1.6666666666666667rem) auto 0px; color: rgb(26, 26, 26); font-family: NittiGrotesk, Keyboard, sans-serif; font-size: 14px;" class="">Effect: Available on OSX 10.8 or newer, and iOS 9.4 or newer.</div><div style="box-sizing: border-box; margin: calc(1.6666666666666667rem) auto 0px; color: rgb(26, 26, 26); font-family: NittiGrotesk, Keyboard, sans-serif; font-size: 14px;" class=""><em style="box-sizing: border-box;" class="">Restricted within Version Bounds</em></div><pre style="box-sizing: border-box; overflow: hidden; font-family: monospace, monospace; font-size: 14px; border-top-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 2px; white-space: pre-wrap; background-color: rgb(230, 230, 230); padding: 1rem; margin: calc(1.6666666666666667rem) auto 0px; color: rgb(26, 26, 26);" class=""><code style="box-sizing: border-box; font-family: NittiPro, Keyboard, monospace; font-size: calc(0.8333333333333334em); border-top-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 2px; padding: 0px;" class="">@restricted(OSX, introduced=10.8, deprecated=10.10, obsoleted=10.11, message="No longer available.")
case LinkedIn = "com.apple.social.linkedin"
</code></pre><div style="box-sizing: border-box; margin: calc(1.6666666666666667rem) auto 0px; color: rgb(26, 26, 26); font-family: NittiGrotesk, Keyboard, sans-serif; font-size: 14px;" class="">Effect: Available on OS X from 10.8 through 10.11 only.</div><div style="box-sizing: border-box; margin: calc(1.6666666666666667rem) auto 0px; color: rgb(26, 26, 26); font-family: NittiGrotesk, Keyboard, sans-serif; font-size: 14px;" class=""><em style="box-sizing: border-box;" class="">Restricted with Renamed Case</em></div><pre style="box-sizing: border-box; overflow: hidden; font-family: monospace, monospace; font-size: 14px; border-top-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 2px; white-space: pre-wrap; background-color: rgb(230, 230, 230); padding: 1rem; margin: calc(1.6666666666666667rem) auto 0px; color: rgb(26, 26, 26);" class=""><code style="box-sizing: border-box; font-family: NittiPro, Keyboard, monospace; font-size: calc(0.8333333333333334em); border-top-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 2px; padding: 0px;" class="">// Initial Release
@restricted(OSX 10.10, *)
case TencentWeibo = "com.apple.social.tencentweibo"
// Second Release
@restricted(OSX, introduced=10.10, deprecated=10.11, renamed="Weibo")
case TencentWeibo = "com.apple.social.tencentweibo"
@restricted(OSX 10.11) case Weibo = "com.apple.social.weibo"
</code></pre><div style="box-sizing: border-box; margin: calc(1.6666666666666667rem) auto 0px; color: rgb(26, 26, 26); font-family: NittiGrotesk, Keyboard, sans-serif; font-size: 14px;" class="">Effect: Initial release case is restricted to 10.10 and newer; second release has the original case deprecated from 10.11, with a new case introduced which is available on OS X 10.11 and newer only. </div><h2 id="benefitsimpactonexistingcode" style="text-align: left; box-sizing: border-box; margin-top: calc(3.3333333333333335rem); margin-bottom: calc(1.6666666666666667rem); font-size: calc(1.1666666666666667rem); line-height: calc(1.4285714285714286); color: rgb(26, 26, 26); font-family: NittiGrotesk, Keyboard, sans-serif;" class="">Benefits & Impact on existing code</h2><div style="box-sizing: border-box; margin: calc(1.6666666666666667rem) auto 0px; color: rgb(26, 26, 26); font-family: NittiGrotesk, Keyboard, sans-serif; font-size: 14px;" class=""><code style="box-sizing: border-box; font-family: NittiPro, Keyboard, monospace; font-size: calc(0.8333333333333334em); border-top-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 2px; white-space: pre-wrap; background-color: rgb(230, 230, 230); padding: 0.1667em 0.3334em 0.25em;" class="">@restricted</code> has the benefit of reducing the amount code while maintaining clarity of purpose: it is obvious based on the attribute name what the intent is. </div><div style="box-sizing: border-box; margin: calc(1.6666666666666667rem) auto 0px; color: rgb(26, 26, 26); font-family: NittiGrotesk, Keyboard, sans-serif; font-size: 14px;" class=""><code style="box-sizing: border-box; font-family: NittiPro, Keyboard, monospace; font-size: calc(0.8333333333333334em); border-top-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 2px; white-space: pre-wrap; background-color: rgb(230, 230, 230); padding: 0.1667em 0.3334em 0.25em;" class="">@restricted</code> is purely additive, and therefore has no impact on existing code that makes use of <code style="box-sizing: border-box; font-family: NittiPro, Keyboard, monospace; font-size: calc(0.8333333333333334em); border-top-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 2px; white-space: pre-wrap; background-color: rgb(230, 230, 230); padding: 0.1667em 0.3334em 0.25em;" class="">@available</code>. </div><h2 id="alternatives" style="text-align: left; box-sizing: border-box; margin-top: calc(3.3333333333333335rem); margin-bottom: calc(1.6666666666666667rem); font-size: calc(1.1666666666666667rem); line-height: calc(1.4285714285714286); color: rgb(26, 26, 26); font-family: NittiGrotesk, Keyboard, sans-serif;" class="">Alternatives</h2><div style="box-sizing: border-box; margin: calc(1.6666666666666667rem) auto 0px; color: rgb(26, 26, 26); font-family: NittiGrotesk, Keyboard, sans-serif; font-size: 14px;" class="">An alternative, though not a strict replacement of <code style="box-sizing: border-box; font-family: NittiPro, Keyboard, monospace; font-size: calc(0.8333333333333334em); border-top-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 2px; white-space: pre-wrap; background-color: rgb(230, 230, 230); padding: 0.1667em 0.3334em 0.25em;" class="">@restricted</code>, could be to extract the <code style="box-sizing: border-box; font-family: NittiPro, Keyboard, monospace; font-size: calc(0.8333333333333334em); border-top-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 2px; white-space: pre-wrap; background-color: rgb(230, 230, 230); padding: 0.1667em 0.3334em 0.25em;" class="">unavailable</code>argument and use it as an attribute (<code style="box-sizing: border-box; font-family: NittiPro, Keyboard, monospace; font-size: calc(0.8333333333333334em); border-top-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 2px; white-space: pre-wrap; background-color: rgb(230, 230, 230); padding: 0.1667em 0.3334em 0.25em;" class="">@unavailable</code>). In use:</div><pre style="box-sizing: border-box; overflow: hidden; font-family: monospace, monospace; font-size: 14px; border-top-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 2px; white-space: pre-wrap; background-color: rgb(230, 230, 230); padding: 1rem; margin: calc(1.6666666666666667rem) auto 0px; color: rgb(26, 26, 26);" class=""><code style="box-sizing: border-box; font-family: NittiPro, Keyboard, monospace; font-size: calc(0.8333333333333334em); border-top-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 2px; padding: 0px;" class="">@available(OSX 10.8, *)
@unavailable(iOS, *)
case LinkedIn = "com.apple.social.linkedin"
</code></pre><div style="box-sizing: border-box; margin: calc(1.6666666666666667rem) auto 0px; color: rgb(26, 26, 26); font-family: NittiGrotesk, Keyboard, sans-serif; font-size: 14px;" class="">Effect: Available on OS X but not iOS.</div><div style="box-sizing: border-box; margin: calc(1.6666666666666667rem) auto 0px; color: rgb(26, 26, 26); font-family: NittiGrotesk, Keyboard, sans-serif; font-size: 14px;" class=""><code style="box-sizing: border-box; font-family: NittiPro, Keyboard, monospace; font-size: calc(0.8333333333333334em); border-top-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 2px; white-space: pre-wrap; background-color: rgb(230, 230, 230); padding: 0.1667em 0.3334em 0.25em;" class="">@unavailable</code> is worthy of further discussion as using an <code style="box-sizing: border-box; font-family: NittiPro, Keyboard, monospace; font-size: calc(0.8333333333333334em); border-top-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 2px; white-space: pre-wrap; background-color: rgb(230, 230, 230); padding: 0.1667em 0.3334em 0.25em;" class="">unavailable</code> argument inside an <code style="box-sizing: border-box; font-family: NittiPro, Keyboard, monospace; font-size: calc(0.8333333333333334em); border-top-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 2px; white-space: pre-wrap; background-color: rgb(230, 230, 230); padding: 0.1667em 0.3334em 0.25em;" class="">@available</code>attribute seems counterintuitive. </div><div style="box-sizing: border-box; margin: calc(1.6666666666666667rem) auto 0px; color: rgb(26, 26, 26); font-family: NittiGrotesk, Keyboard, sans-serif; font-size: 14px;" class="">However, this proposal is limited to the consideration of <code style="box-sizing: border-box; font-family: NittiPro, Keyboard, monospace; font-size: calc(0.8333333333333334em); border-top-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 2px; white-space: pre-wrap; background-color: rgb(230, 230, 230); padding: 0.1667em 0.3334em 0.25em;" class="">@restricted</code>.</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>