<div dir="ltr">On 4 October 2017 at 14:24, Alex Blewitt <span dir="ltr">&lt;<a href="mailto:alblue@apple.com" target="_blank">alblue@apple.com</a>&gt;</span> wrote:<div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word"><div><span class="gmail-"><blockquote type="cite"><div><div dir="ltr">On 4 October 2017 at 13:41, Alex Blewitt <span dir="ltr">&lt;<a href="mailto:alblue@apple.com" target="_blank">alblue@apple.com</a>&gt;</span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word"><span class="gmail-m_2794792124588821558gmail-"><div><br></div></span><div>The difference between the &amp; and &amp;&amp; operators isn&#39;t to do with the implicit conversions; it&#39;s to do with whether both sides of the expression are evaluated or not.</div></div></blockquote></div></div></div></div></blockquote></span><br></div><div>However, you can wrap the second argument in an @autoclosure, which means it replaces the body of the expression with a function that evaluates the expression automatically:</div><div><br></div><div><div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures">infix operator &amp;&amp;&amp;: LogicalConjunctionPrecedence</span></div><div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255);min-height:13px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></div><div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures">func &amp;&amp;&amp;(left: Bool, right: @autoclosure () -&gt; Bool) -&gt; Bool {</span></div><div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures"><span class="gmail-m_2794792124588821558Apple-tab-span" style="white-space:pre-wrap">        </span>return left &amp;&amp; right()</span></div><div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures">}</span></div></div></div></blockquote><div><br></div><div>great. as you just shown, the difference of short-circuiting or not is not inside the operator declaration itself (like it is defined in C)</div><div>but in the actual operator implementation, so we can have:</div><div><br></div><div>infix operator &amp;&amp;&amp;: LogicalConjunctionPrecedence</div><div><br></div><div>func &amp;&amp;&amp;(left: Bool, right: @autoclosure () -&gt; Bool) -&gt; Bool {</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>return left &amp;&amp; right()</div><div>}</div><div><br></div><div>func &amp;&amp;&amp;(left: Int, right: Int) -&gt; Int {</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>return left &amp; right</div><div>}</div><div><br></div><div>where the logical one short-circuits and bit-wise one doesn&#39;t.</div><div><br></div><div>Mike</div><div><br></div></div></div></div>