<div dir="ltr">I think if we did feature detection it should ignore private methods not accessible by the code querying its accesbility. Additionally we really do need proper support across platforms.</div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr">
<p><b><font color="#cc0000">___________________________________</font></b></p><p><b>James⎥Lead Engineer</b></p><p><b><font color="#cc0000"><a href="mailto:james@supmenow.com" target="_blank">james@supmenow.com</a>⎥<a href="http://supmenow.com" target="_blank">supmenow.com</a></font></b></p><p><b><font size="2">Sup</font></b></p><p><b><font size="2">Runway East
</font></b></p><p><b><font size="2">10 Finsbury Square</font></b></p><p><b><font size="2">London</font></b></p><p><b><font size="2">
EC2A 1AF </font></b></p></div></div></div></div></div>
<br><div class="gmail_quote">On Wed, Feb 3, 2016 at 9:03 PM, Douglas Gregor via swift-evolution <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><br><div><span class=""><blockquote type="cite"><div>On Feb 3, 2016, at 1:02 PM, Félix Cloutier <<a href="mailto:felixcca@yahoo.ca" target="_blank">felixcca@yahoo.ca</a>> wrote:</div><br><div><div style="word-wrap:break-word">Won't it be a concern with a cross-platform Swift?<br></div></div></blockquote><div><br></div></span>#available is currently only implemented for Apple platforms. If someone wants to extend it to another platform, they need to do so in a manner that gives it consistent semantics.</div><div><br></div><div><span style="white-space:pre-wrap">        </span>- Doug</div><div><div class="h5"><div><br><blockquote type="cite"><div><div style="word-wrap:break-word"><div>
<br><span style="font-family:'Lucida Grande';font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">Félix</span>
</div>
<br><div><blockquote type="cite"><div>Le 3 févr. 2016 à 15:47:15, Douglas Gregor via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> a écrit :</div><br><div><div style="font-family:LucidaGrande;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><blockquote type="cite"><div><br>On Feb 3, 2016, at 5:10 AM, Jean-Daniel Dupas via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> wrote:</div><br><div><div style="word-wrap:break-word">Using function availability has proven fragile in the past too. A function may be present but private on older system, and have a slightly different behavior or crash, and so should not be used.</div></div></blockquote><div><br></div><div>This is a failing of the -respondsToSelector: idiom for checking availability. Swift’s #available feature checks the actual OS version, so it doesn’t suffer from this problem.</div><div><br></div><span style="white-space:pre-wrap">        </span>- Doug</div><div style="font-family:LucidaGrande;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br><blockquote type="cite"><div><div style="word-wrap:break-word"><div><br></div><div><div><br><div><blockquote type="cite"><div>Le 2 févr. 2016 à 11:03, James Campbell via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> a écrit :</div><br><div><div dir="ltr">Coming from a web background (before my iOS career) to me #avaliable has huge problem. It encourages fragility.<div><br></div><div>In my eyes we should encourage two types of detection: Features to make code more adaptable to different environments and language version detection: so we can understand the actual code.</div><div><br></div><div>See this example below:</div><div><br></div><div>func magic(object: Object)</div><div>{</div><div> if(#avaliable(9.0, 10))</div><div> {</div><div> object.foo()</div><div> }</div><div>}</div><div><br></div><div>Ideally for me I would love to check if the foo function exists like so:</div><div><br></div><div><div>func iOS9OnlyProtocolFunction(object: Object)</div><div>{</div><div> if(#avaliable(Object.foo))</div><div> {</div><div> object.foo()</div><div> }</div><div>else </div><div>{</div><div> object.baz()</div><div> }</div><div>}</div><div><br></div><div>I think this encourages feature detection which results in less fragile code. What I would love to do is also to extend this to extensions so we could encourage polyfills.</div><div><br></div><div>extend object where not_avaliable(Object.foo) </div><div>{</div><div> func foo() </div><div> {</div><div> //Polyfill for platforms which don't support the Object.foo method</div><div> }</div><div>}</div><div><br></div><div>Not sure about compiler details but being able to polyfill the function results in much cleaner code for me. I love this approach from the web, so I created my own Objective-C Library to do this:</div><div><br></div><div><a href="https://github.com/jcampbell05/Polly" target="_blank">https://github.com/jcampbell05/Polly</a><br></div><div><div><div dir="ltr"><div><div dir="ltr"><p><b><font color="#cc0000">___________________________________</font></b></p><p><b>James⎥Lead Engineer</b></p><p><b><font color="#cc0000"><a href="mailto:james@supmenow.com" target="_blank">james@supmenow.com</a>⎥<a href="http://supmenow.com/" target="_blank">supmenow.com</a></font></b></p><p><b><font size="2">Sup</font></b></p><p><b><font size="2">Runway East
</font></b></p><p><b><font size="2">10 Finsbury Square</font></b></p><p><b><font size="2">London</font></b></p><p><b><font size="2">
EC2A 1AF </font></b></p></div></div></div></div></div></div></div>_______________________________________________<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" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br></div></blockquote></div><br></div></div></div>_______________________________________________<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" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br></div></blockquote></div><br style="font-family:LucidaGrande;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="font-family:LucidaGrande;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">_______________________________________________</span><br style="font-family:LucidaGrande;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="font-family:LucidaGrande;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">swift-evolution mailing list</span><br style="font-family:LucidaGrande;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><a href="mailto:swift-evolution@swift.org" style="font-family:LucidaGrande;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank">swift-evolution@swift.org</a><br style="font-family:LucidaGrande;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" style="font-family:LucidaGrande;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a></div></blockquote></div><br></div></div></blockquote></div><br></div></div></div><br>_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">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>
<br></blockquote></div><br></div>