<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div><br></div><div>On Oct 4, 2017, at 6:41 AM, Alex Blewitt via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br><br></div><blockquote type="cite"><div><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><div><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" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><span style="font-size:12.800000190734863px" class="">on Tue, 3 Oct 2017 11:00:33 -0600&nbsp;</span><span style="font-size:12.800000190734863px" class="">Dave DeLong &lt;</span><a href="mailto:swift@davedelong.com" style="font-size:12.800000190734863px" class="">swift@davedelong.com</a><span style="font-size:12.800000190734863px" class="">&gt;</span><br style="font-size:12.800000190734863px" class="">&nbsp; wrote:<div class=""><span style="font-size:12.800000190734863px" class=""><br class=""></span></div><div class=""><span style="font-size:12.800000190734863px" class="">&gt; Because, ideally, I’d love to be able to do:</span><br style="font-size:12.800000190734863px" class="">&gt;&nbsp;<br style="font-size:12.800000190734863px" class=""><span style="font-size:12.800000190734863px" class="">&gt; infix operator and: LogicalConjunctionPrecedence // or whatever the precedence is called</span><br style="font-size:12.800000190734863px" class=""><span style="font-size:12.800000190734863px" class="">&gt; func and(lhs: Bool, rhs: Bool) → Bool { return lhs &amp;&amp; rhs }</span><br style="font-size:12.800000190734863px" class="">&gt;&nbsp;<br style="font-size:12.800000190734863px" class=""><span style="font-size:12.800000190734863px" class="">&gt; let truthyValue = true and false</span><div class="gmail_extra"><br class=""></div><div class="gmail_extra">+1 (i like your thinking, even if it is unlikely to happen in swift)</div><div class="gmail_extra"><br class=""></div><div class="gmail_extra">(noteworthy, your example used "RIGHTWARDS ARROW" (U+2192) instead of -&gt;, whether on purpose or not.)</div></div></div></div></blockquote></div></div></blockquote><div><br></div><div>Heh, right. That was unintentional. I have system text replacements set up to turn -&gt;, =&gt;, &lt;-&gt;, etc in to their Unicode arrow versions: →, ⇒, ↔︎&nbsp;</div><div><br></div><div>And using words (and even phrases &nbsp;like “is not”) as operators is totally possible. It would just require the parser to have a known list of all operators, and then greedily match characters as long as there’s an operator that’s prefixed by the current token, and then backtrack when it fails.&nbsp;</div><div><br></div><div>I implemented this style of operator definition and parsing in my open source math parsing library: <a href="https://github.com/davedelong/DDMathParser">https://github.com/davedelong/DDMathParser</a>&nbsp;</div><div><br></div><div>Dave</div><br><blockquote type="cite"><div><div><blockquote type="cite" class=""><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><div>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><br class=""></div><div>false &amp;&amp; system('rm -rf')</div><div><br class=""></div><div>You really don't want to do that if both sides are executed ...</div><div><br class=""></div><div>Alex</div><br class=""></div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>swift-evolution mailing list</span><br><span><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br></div></blockquote></body></html>