<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div><span></span></div><div><meta http-equiv="content-type" content="text/html; charset=utf-8"><div></div><div><br></div><div>Am 05.04.2016 um 17:29 schrieb Антон Жилин &lt;<a href="mailto:antonyzhilin@gmail.com">antonyzhilin@gmail.com</a>&gt;:<br><br></div><blockquote type="cite"><div dir="ltr">David Waite stated a major drawback of precedence groups.<div><br></div><div>People will often create tiny precedence groups for their modules, and user will find that some of them should actually be the same. They will add precedenceEqualTo, but all these equivalent groups will still exist. This problem cannot occur with transitive precedence propagation. So precedence groups really create more problems than solve.</div><div><br></div><div>- Anton</div><div><br></div></div></blockquote><div><br></div><div><div><span style="background-color: rgba(255, 255, 255, 0);">Do you mean these drawbacks?</span></div><div><span style="background-color: rgba(255, 255, 255, 0);"><br></span></div><div><span style="background-color: rgba(255, 255, 255, 0);">"</span></div><div><div class=""></div><blockquote type="cite"><div class=""><font color="#000000"><span style="background-color: rgba(255, 255, 255, 0);">However, this may create more issues than it solves (two frameworks creating their own custom operators, putting them in custom precedence groups, and the consumer decides the two precedence groups are really equivalent)</span></font></div><div class=""><font color="#000000"><span style="background-color: rgba(255, 255, 255, 0);"><br class=""></span></font></div><div class=""><font color="#000000"><span style="background-color: rgba(255, 255, 255, 0);">-DW</span></font></div></blockquote><span style="background-color: rgba(255, 255, 255, 0);">"</span></div><div><span style="background-color: rgba(255, 255, 255, 0);"><br></span></div><div><span style="background-color: rgba(255, 255, 255, 0);">What is the problem? Changing the relative precedence of external operators in your file? Doesn't the same "problem" occur in your proposal (only with one operator)?</span></div><div><span style="background-color: rgba(255, 255, 255, 0);"><br></span></div><div><span style="background-color: rgba(255, 255, 255, 0);">What is the difference between overriding an operator function like this:</span></div><div><span style="background-color: rgba(255, 255, 255, 0);"><br></span></div><div><span style="background-color: rgba(255, 255, 255, 0);">func + (l: Int, r: Int) -&gt; Int {</span></div><div><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; &nbsp; &nbsp; &nbsp;return 0</span></div><div><span style="background-color: rgba(255, 255, 255, 0);">}</span></div><div><span style="background-color: rgba(255, 255, 255, 0);"><br></span></div><div><span style="background-color: rgba(255, 255, 255, 0);">This can also mess up your code...</span></div></div><div>I'm sorry if I haven't understood your point.</div><div><br></div><div>From the other email:</div><div><br></div><div><div></div><blockquote type="cite"><div><span style="background-color: rgba(255, 255, 255, 0);">I meant, are names `precedenceLessThan`, `precedenceEqualTo` a bit clunky? Maybe:</span></div><div><span style="background-color: rgba(255, 255, 255, 0);"><br></span></div><div><span style="background-color: rgba(255, 255, 255, 0);">associativity(left)</span></div><div><span style="background-color: rgba(255, 255, 255, 0);">precedence(lessThan: +)</span></div><div><span style="background-color: rgba(255, 255, 255, 0);">precedence(equalTo: +)</span></div><div><span style="background-color: rgba(255, 255, 255, 0);"><br></span></div><div><span style="background-color: rgba(255, 255, 255, 0);">It also solves my concern about dictionary inside braces.</span></div></blockquote><br></div><div>I prefer "precedence(+ lessThan *)". However I don't think it's Swift style since "lessThan" is like an infix operator <b>with letters </b>although the symmetry between "+" and "*" would be nicely handled by such operator.</div><div><br></div><div><blockquote type="cite"><span style="background-color: rgba(255, 255, 255, 0);">Precedence groups have a great benefit of additional symmetry. Transitive precedence propagation, on the other hand, also has benefits:</span><div><span style="background-color: rgba(255, 255, 255, 0);"><br></span><div><span style="background-color: rgba(255, 255, 255, 0);">1. It does not introduce new entities, just some rules for compiler</span></div><div><span style="background-color: rgba(255, 255, 255, 0);">2. It does not add new keywords. In&nbsp;your current wording, we have to take precedence and precedenceGroup as keywords, that's why I originally&nbsp;preferred directives</span></div></div></blockquote><div><br></div><div>Both 1 and 2 are true but I still prefer to use declarations since they provide exactly one location where to put operators with equal precedence.</div><div><br></div><div>By the way "precedence" is already a keyword... One more to go :)</div><br><blockquote type="cite"><div><div><span style="background-color: rgba(255, 255, 255, 0);">3. We actually think in terms of operators, not groups.</span></div><div><span style="background-color: rgba(255, 255, 255, 0);">If I want to say that my operator should have the same priority as `+`, I'd rather&nbsp;say that I want it to have priority of plus and minus, not "belong to multiplicative group".</span></div><div><span style="background-color: rgba(255, 255, 255, 0);">If I&nbsp;declare&nbsp;&lt;$&gt; and want it&nbsp;to have same priority as &lt;*&gt;, it would be more difficult&nbsp;to invent some name for their&nbsp;group&nbsp;like FunctorManipulator.</span></div><div><span style="background-color: rgba(255, 255, 255, 0);"><br></span></div></div></blockquote><div><br></div><div>I think this deserves more discussion:</div><div>Should we allow "precedence(... equalTo ...)" for operators if we have precedence groups?</div><div><br></div><div>Such a precedence declaration would be contrary to my argument above: declare equal operator precedences in one place, which is more maintainable.</div><br><blockquote type="cite"><div><div><span style="background-color: rgba(255, 255, 255, 0);">On the other hand, in your solution you&nbsp;have a list of global rules and&nbsp;don't really need braces. How about this?</span></div></div><div><span style="background-color: rgba(255, 255, 255, 0);"><br></span></div><span style="background-color: rgba(255, 255, 255, 0);">#precedenceGroup(Additive)</span><div><span style="background-color: rgba(255, 255, 255, 0);">#precedenceGroup(Multiplicative)</span></div><div><span style="background-color: rgba(255, 255, 255, 0);">#precedence(Additive, less, Multiplicative)</span></div><span style="background-color: rgba(255, 255, 255, 0);">#operator(+, infix,&nbsp;associativity: left, group: Additive)</span><div><span style="background-color: rgba(255, 255, 255, 0);">#operator(*,&nbsp;infix,&nbsp;associativity: left, group: Multiplicative)</span></div><div><span style="background-color: rgba(255, 255, 255, 0);">#operator(&lt;&gt;, infix)</span></div><div><span style="background-color: rgba(255, 255, 255, 0);"><br></span></div><div><span style="background-color: rgba(255, 255, 255, 0);">So precedence&nbsp;group&nbsp;is just a tag that can be used in precedence rules and assigned to operators at declaration.</span></div></blockquote><br></div><div>Although it is consistent with your proposal for me it is too much repetition and "code noise". Compare:</div><div><br></div><div>infix operator + {&nbsp;<span style="background-color: rgba(255, 255, 255, 0);">associativity: left }</span></div><div><span style="background-color: rgba(255, 255, 255, 0);">infix operator * {&nbsp;associativity: left }</span></div><div><span style="background-color: rgba(255, 255, 255, 0);">infix operator &lt;&gt; {}</span></div><div>precedenceGroup Additive { + }</div><div>precedenceGroup Multiplicative { * }</div><div>precedence(Additive lessThan Multiplicative)</div><div><br></div><div>Which is in my opinion way more readable even without syntax highlighting.</div><div><br></div><div><br></div><div>Thank You for sharing Your thoughts which have enriched me! :)</div><div><br></div><div>Best regards</div><div>- Maximilian</div><blockquote type="cite"><div dir="ltr"><div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
</blockquote></div>
</div>
</blockquote></div></body></html>