<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">https://github.com/jcampbell05/Polly</a><br></div><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>
</div></div>