Apr 5, 2016, Maximilian Hünenberger  wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div></div><div></div><div><br></div><div>Am 04.04.2016 um 08:06 schrieb Антон Жилин &lt;<a href="javascript:_e(%7B%7D,&#39;cvml&#39;,&#39;antonyzhilin@gmail.com&#39;);" target="_blank">antonyzhilin@gmail.com</a>&gt;:<br></div><blockquote type="cite"><div dir="ltr"><div><div>Is it OK to have &quot;less, equal, greater&quot; in precedence name?</div></div></div></blockquote><div>What do you mean by OK? Other operators like == are weird:</div><div><br></div><div>precedence(== == &lt;)</div><div>// in comparison to</div><div>precedence(== equalTo &lt;)</div></div></blockquote><div><br></div><div>I meant, are names `precedenceLessThan`, `precedenceEqualTo` a bit clunky? Maybe:</div><div><br></div><div>associativity(left)</div><div>precedence(lessThan: +)</div><div>precedence(equalTo: +)</div><div><br></div><div>It also solves my concern about dictionary inside braces.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div>After thinking more about it I came to the conclusion that we should have something like &quot;precedence groups&quot; where all operators have the same precedence:<br></div><div><br></div><div>precedenceGroup Additive {</div><div>    +, -</div><div>}</div><div><br></div><div><span style="background-color:rgba(255,255,255,0)">precedenceGroup</span> Multiplicative {</div><div>    *, /</div><div>}</div><div><br></div><div>precedence(Additive lessThan Multiplicative)</div><div><span style="background-color:rgba(255,255,255,0)"><br></span></div><div><span style="background-color:rgba(255,255,255,0)">infix operator +- {</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)">}</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)">extension Additive {</span></div><div><span style="background-color:rgba(255,255,255,0)">    +-, -+, ++, --</span></div><div><span style="background-color:rgba(255,255,255,0)">}</span></div><div></div></div></blockquote><div><br></div>Precedence groups have a great benefit of additional symmetry. Transitive precedence propagation, on the other hand, also has benefits:<div><br><div>1. It does not introduce new entities, just some rules for compiler</div><div>2. It does not add new keywords. In your current wording, we have to take precedence and precedenceGroup as keywords, that&#39;s why I originally preferred directives</div><div>3. We actually think in terms of operators, not groups.</div><div>If I want to say that my operator should have the same priority as `+`, I&#39;d rather say that I want it to have priority of plus and minus, not &quot;belong to multiplicative group&quot;.</div><div>If I declare &lt;$&gt; and want it to have same priority as &lt;*&gt;, it would be more difficult to invent some name for their group like FunctorManipulator.</div><div><br></div><div>On the other hand, in your solution you have a list of global rules and don&#39;t really need braces.  How about this?</div></div><div><br></div>#precedenceGroup(Additive)<div>#precedenceGroup(Multiplicative)</div><div>#precedence(Additive, less, Multiplicative)</div>#operator(+, infix, associativity: left, group: Additive)<div>#operator(*, infix, associativity: left, group: Multiplicative)</div><div>#operator(&lt;&gt;, infix)</div><div><br></div><div>So precedence group is just a tag that can be used in precedence rules and assigned to operators at declaration.</div>