<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div><br><br>Sent from my iPad</div><div><br>On May 19, 2016, at 4:07 PM, Антон Жилин <<a href="mailto:antonyzhilin@gmail.com">antonyzhilin@gmail.com</a>> wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr">OK, question 2 closed, we do need unlimited relationships.<div>Some critique to Brent's options:</div><div>1. No separators, with multiple relations it becomes unobvious, which comparison corresponds to which group</div><div>2. `left` appears suddenly, it may not be clear that it is associativity</div><div>3. Where is declaration of the precedence group? It looks like two relationship declarations, but in Swift, all entities tend to be pre-declared</div><div>4. Remove @, otherwise not that bad</div><div>5. Actually, that was the very first version of the proposal. Over time, it morphed to version in alternative solutions:</div><div><br></div><div><div style="font-size:12.8px">precedencegroup B : associativity(left)</div><div style="font-size:12.8px">precedencerelation B > A</div><div style="font-size:12.8px">precedencerelation B < C</div></div><div><br></div><div>The specific syntax is discussable:</div><div><br></div><div><div style="font-size:12.8px">precedencegroup <span style="font-size:12.8px">associativity(left) </span><span style="font-size:12.8px">B</span></div><div style="font-size:12.8px">precedence B > A</div><div style="font-size:12.8px">precedence B < C</div></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">We could also stretch inheritance-like syntax:</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">precedence B : associativity(left), above(A), below(C)</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">That is my current favourite among one-liners, if we don't want separate relationship declaration.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">On Matthew's version: I like that it is lightweight, but I don't like that `left` is a "sudden" word again, and that relationships turn into a mess when written on a single line.</div></div></div></blockquote><div><br></div><div>I suggested adopting two variants. Use Brent's original syntax for single relation declarations and use the multi-line braced variant for multiple relations. We could require the new line separator in the braced version.</div><div><br></div><div>If you don't want to have left unadorned maybe we do this for the shorthand:</div><div><br></div><div><div dir="ltr"><div><font color="#000000"><span style="background-color: rgba(255, 255, 255, 0);">precedence B > A associativity left</span></font></div><div><font color="#000000"><span style="background-color: rgba(255, 255, 255, 0);"><br></span></font></div><div><font color="#000000"><span style="background-color: rgba(255, 255, 255, 0);">And this for multiple relations:</span></font></div><div><font color="#000000"><span style="background-color: rgba(255, 255, 255, 0);"><br></span></font></div><div>precedence C {</div><div><span style="background-color: rgba(255, 255, 255, 0);"> > A</span></div><div><span style="background-color: rgba(255, 255, 255, 0);"> < B</span></div><div><span style="background-color: rgba(255, 255, 255, 0);"> associativity left</span></div><div>}</div><div><br></div><div>In the multiple relation option we could allow associativity to appear at any position in the list or require it to be last for consistency with the single line syntax.</div></div></div><br><blockquote type="cite"><div><div dir="ltr"><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">- Anton</div><div style="font-size:12.8px"><br></div><div class="gmail_extra"><div class="gmail_quote">2016-05-19 23:36 GMT+03:00 Brent Royal-Gordon <span dir="ltr"><<a href="mailto:brent@architechies.com" target="_blank">brent@architechies.com</a>></span>:<br><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"><span>> I managed to confuse at least two people! I've stated it in the grammar, but forgot to give an example:<br>
><br>
> ===begin===<br>
> Multiple precedence relationships can be stated for a single precedence group. Example:<br>
> ```swift<br>
> precedencegroup A { }<br>
> precedencegroup C { }<br>
> precedencegroup B { precedence(> A) precedence(< C) }<br>
> ```<br>
> By transitivity, precedence of C becomes greater than precedence of A.<br>
> ===end===<br>
><br>
> As you can see, your suggested syntax would not look good, because there can be any number of precedence declarations.<br>
<br>
</span>Ah, I see.<br>
<span><br>
> 2. Limit precedence relationships.<br>
><br>
> Do we really need a full-blown Directed Acyclic Graph?<br>
> Could `above` and `between` be enough?<br>
><br>
> Example:<br>
><br>
> precedencegroup B : between(A, C)<br>
><br>
> This is one of dark places of the proposal, obviously underdiscussed.<br>
> Are there practical situations other than `above` and `between`?<br>
> Do we really need unlimited relationships per one precedencegroup?<br>
<br>
</span>We probably do if you're serious about having operators whose precedence relative to each other is undefined. Moreover, you actually have to be prepared for *more than* two relationships, or two relationships which are both on the same "side", so "between" doesn't cut the mustard.<br>
<br>
I can see three ways to fit multiple relationships on one line:<br>
<br>
1. precedence Multiplicative > Additive < BitwiseShift left<br>
2. precedence Multiplicative > Additive, < BitwiseShift left<br>
3. precedence Multiplicative > Additive, Multiplicative < BitwiseShift left<br>
<br>
Another option would be to have `precedence` lines declare-or-redeclare *all* of the precedence levels in them, not just the one on the left of the operator. Then you would write something like:<br>
<br>
4. precedence @associativity(left) Multiplicative > Additive<br>
precedence Multiplicative < BitwiseShift<br>
<br>
It would be an error to have two `precedence` lines which marked the same precedence level with a different `@associativity`. Of course, we could instead put associativity on its own line, perhaps allowing multiple declarations for compactness:<br>
<br>
5. precedence Multiplicative > Additive<br>
precedence Multiplicative < BitwiseShift<br>
associativity left Cast, Comparative, Multiplicative, Additive<br>
<br>
I think 5 is my preference, but if we want a single-line syntax, I'd probably favor 2.<br>
<span><font color="#888888"><br>
--<br>
Brent Royal-Gordon<br>
Architechies<br>
<br>
</font></span></blockquote></div><br></div></div>
</div></blockquote></body></html>