<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>Yeah I saw that thread. I think (a) this is a better solution and (b) this is applicable for use cases other than specifically Glibc/Darwin.</div><div id="AppleMailSignature"><br></div><div id="AppleMailSignature">-Sean<br><br>Sent from my iPhone</div><div><br>On Oct 17, 2016, at 19:01, Saagar Jha &lt;<a href="mailto:saagar@saagarjha.com">saagar@saagarjha.com</a>&gt; wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr">I believe there was a draft to merge all the "Libc" modules; let me see if I can find that.</div><br><div class="gmail_quote"><div dir="ltr">On Mon, Oct 17, 2016 at 3:06 PM Sean Alling via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br></div><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="gmail_msg"><div class="gmail_msg"><u class="gmail_msg"><b class="gmail_msg">Description</b></u></div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">In an effort to both (1) reduce boilerplate code, and (2) promote cross-platform reusability I propose that we implement the following&nbsp;<b class="gmail_msg">Import Conditional Operators</b>:&nbsp;</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><b class="gmail_msg">`||`&nbsp;</b>and `<b class="gmail_msg">&amp;&amp;`</b></div><div class="gmail_msg"><b class="gmail_msg"><br class="gmail_msg"></b></div><div class="gmail_msg">Currently, import conditionals must be implemented like so:</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">```</div><div class="gmail_msg">#if os(Linux) || os(FreeBSD)<br class="gmail_msg"><span class="m_4870885646406276582Apple-tab-span gmail_msg" style="white-space:pre-wrap">        </span>import Glibc<br class="gmail_msg">#else<br class="gmail_msg"><span class="m_4870885646406276582Apple-tab-span gmail_msg" style="white-space:pre-wrap">        </span>import Darwin<br class="gmail_msg">#endif</div><div class="gmail_msg">```</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">With <b class="gmail_msg">import&nbsp;conditional operators</b>&nbsp;this would be condensed to:</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">```</div><div class="gmail_msg">import Glibc || Darwin</div><div class="gmail_msg">```</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">The first library/framework (Glibc) would be imported if found and the the second (Darwin) only in the event the first should fail.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><b class="gmail_msg"><u class="gmail_msg">Other Caveats:</u></b></div><div class="gmail_msg"><b class="gmail_msg"><u class="gmail_msg"><br class="gmail_msg"></u></b></div><div class="gmail_msg"><b class="gmail_msg">(A) — &nbsp;</b>we could limit this to one conditional operator per import line OR we could implement order of operations. Obviously, there are tradeoffs of both that we should discuss.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><b class="gmail_msg">(B) —</b>&nbsp;if-conditional statements currently explicitly show the import conditions (i.e., os(Linux) || os(FreeBSD)) this would be a detriment to this new feature. I would argue that the reduction of boilerplate code would in itself be worth this abstraction.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">--</div><div class="gmail_msg">Sean Alling</div><div class="gmail_msg"><br class="gmail_msg"></div></div>_______________________________________________<br class="gmail_msg">
swift-evolution mailing list<br class="gmail_msg">
<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a><br class="gmail_msg">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="gmail_msg">
</blockquote></div>
</div></blockquote></body></html>