<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div><blockquote type="cite" class=""><div class="">On 4 Oct 2017, at 13:55, Mike Kluev &lt;<a href="mailto:mike.kluev@gmail.com" class="">mike.kluev@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">On 4 October 2017 at 13:41, Alex Blewitt <span dir="ltr" class="">&lt;<a href="mailto:alblue@apple.com" target="_blank" class="">alblue@apple.com</a>&gt;</span> wrote:<br class=""><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space" class=""><span class=""><div class=""><blockquote type="cite" class=""><div class="">On 4 Oct 2017, at 11:42, Mike Kluev via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt; wrote:</div><div class=""><div dir="ltr" class=""><div class="gmail_extra"><br class=""></div><div class="gmail_extra">speaking of &amp;&amp;, was it just a copy-paste from C or is there a more fundamental reason to use that instead of &amp;? in C they had to use two different operators because of the implicit int &lt;-&gt; bool promotions, but in swift "true &amp; false" vs "1 &amp; 2" would have been distinguishable.</div></div></div></blockquote><br class=""></div></span><div class="">The difference between the &amp; and &amp;&amp; operators isn't to do with the implicit conversions; it's to do with whether both sides of the expression are evaluated or not.</div><div class=""><br class=""></div><div class="">false &amp;&amp; system('rm -rf')</div><div class=""><br class=""></div><div class="">You really don't want to do that if both sides are executed ...</div></div></blockquote><div class=""><br class=""></div><div class="">true. however what would stop the hypothetical "logical &amp;" operator to not evaluate the right hand side if the left&nbsp;</div><div class="">side is false similar to how &amp;&amp; behaves? yes, it would make it more different to the "bitwise &amp;" operator, but they are</div><div class="">already a bit different.</div></div></div></div></div></blockquote><div><br class=""></div><div>Whether you are dealing with boolean/int types and whether you short-circuit the operators are orthogonal concerns.</div><br class=""><blockquote type="cite" class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class="">(it was always backwards to me even in C: bitwise *single* &amp; is for and-ing *multiple* bit pairs, whilst a</div><div class="">*multi-character* &amp;&amp; is for and-ing a single bool pair.)</div></div></div></div></blockquote></div><br class=""><div class="">The &amp;&amp; (c.f. ||) is explicitly for short-circuiting and is nothing to do with bit pairs or booleans, by specification.</div><div class=""><br class=""></div><div class="">See e.g. section 6.5.13 and 6.5.14.</div><div class=""><br class=""></div><div class=""><a href="http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf" class="">http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf</a></div><div class=""><br class=""></div><div class="">Alex</div></body></html>