<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">I think the teacher should just do a better job explaining group theory ;) Its perfectly consistent to treat * and &amp; separately, because they de-facto interpret their arguments as different types.&nbsp;<div class=""><br class=""></div><div class=""><div class="">— T<br class=""><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 15 Feb 2016, at 20:17, Xiaodi Wu 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 style="white-space:pre-wrap" class="">Yes, but not enough to claim limited resources needed for pressing matters. It's not a feature anyone would clamor for, more a product of the foolish consistency hobgoblin. Rationale: it is possible in JavaScript (for instance) to evaluate true * true, but not in Swift. [I'm aware that implicit casting is taking place in JavaScript, and that the return type isn't a Boolean.] It comes into play in exactly one scenario I can think of:<br class=""><br class="">Student: "Why is &amp; a multiplicative operation?"<br class="">Teacher: "Well, because for two bits A and B, A &amp; B == A * B."<br class="">Student: "That's interesting, let me try it with the only type I know that represents a single bit of data."<br class="">[At this point the student should, IMO, be able to actually evaluate A * B where A and B are booleans.]<br class=""><br class="">Analogous rationale for defining &amp;+ and &amp;- on booleans.</div><br class=""><div class="gmail_quote"><div dir="ltr" class="">On Mon, Feb 15, 2016 at 12:20 PM Chris Lattner &lt;<a href="mailto:clattner@apple.com" class="">clattner@apple.com</a>&gt; wrote:<br class=""></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=""><div class=""><blockquote type="cite" class=""><div class="">On Feb 14, 2016, at 10:25 AM, Xiaodi Wu &lt;<a href="mailto:xiaodi.wu@gmail.com" target="_blank" class="">xiaodi.wu@gmail.com</a>&gt; wrote:</div><br class=""><div class="">Some further study has been helpful. Am I close to the mark in answering my own question?<br class=""><br class="">- Further reading shows that Swift's rationalized operator precedence levels broadly align with those of Erlang and Go. (However, those languages also seem to lack documentation on how they arrived at this set of precedence levels.)<br class=""><br class="">- It is quite evident why &lt;&lt; is considered exponentiative.<br class=""><br class="">- Dennis Ritchie has explained &lt;<a href="http://www.lysator.liu.se/c/dmr-on-or.html" target="_blank" class="">http://www.lysator.liu.se/c/dmr-on-or.html</a>&gt; why &amp; has lower precedence than == in C, and why in hindsight that is better off changed. This change has been implemented in Swift/Go/Erlang and also in other languages like Python.<br class=""><br class="">- &amp; is considered multiplicative because for two bits A and B, A &amp; B == A * B.<br class=""><br class="">- ^ and | should have equal precedence to - and +, respectively, by analogous reasoning.<br class=""><br class="">- It also happens to be rational for &amp; to have higher precedence than | by analogy with &amp;&amp; and ||.<br class=""></div></blockquote><div class=""><br class=""></div></div></div><div style="word-wrap:break-word" class=""><div class=""><div class="">Yep, this is all right.</div></div></div><div style="word-wrap:break-word" class=""><div class=""><br class=""><blockquote type="cite" class=""><div class="">It's a bit of a bummer, if this line of reasoning was indeed used in arriving at these operator precedence levels, that Swift will not allow evaluation of true * true (etc.) without casting. I would expect true &amp; true == true * true.<br class=""></div></blockquote></div></div><div style="word-wrap:break-word" class=""><div class=""></div><br class=""><div class="">I’m not sure what you mean here.&nbsp; You want multiplication defined on booleans?</div></div><div style="word-wrap:break-word" class=""><div class=""><br class=""></div><div class="">-Chris</div></div></blockquote></div>
_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></div></div></div></body></html>