<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 <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> 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 <b class="gmail_msg">Import Conditional Operators</b>: </div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><b class="gmail_msg">`||` </b>and `<b class="gmail_msg">&&`</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 conditional operators</b> 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) — </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> 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>