<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=""><br class=""><div><blockquote type="cite" class=""><div class="">On May 19, 2016, at 3:07 PM, Антон Жилин 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=""><div class="">Thanks Brent,</div><div class=""><br class=""></div><div class="">I managed to confuse at least two people! I've stated it in the grammar, but forgot to give an example:</div><div class=""><br class=""></div><div class="">===begin===</div><div class=""><div class="">Multiple precedence relationships can be stated for a single precedence group. Example:</div><div class="">```swift</div><div class="">precedencegroup A { }</div><div class="">precedencegroup C { }</div><div class="">precedencegroup B { precedence(&gt; A) precedence(&lt; C) }</div><div class="">```</div><div class="">By transitivity, precedence of C becomes greater than precedence of A.</div></div><div class="">===end===</div><div class=""><br class=""></div><div class="">As you can see, your suggested syntax would not look good, because there can be any number of precedence declarations.</div><div class=""><br class=""></div><div class="">But I agree that bulkiness of my syntax is a problem.</div><div class="">I can think of two solutions:</div><div class=""><br class=""></div><div class="">1. Global-scope precedence relationships. Example:</div><div class=""><br class=""></div><div class="">precedencegroup B : associativity(left)</div><div class="">precedencerelation B &gt; A</div><div class="">precedencerelation B &lt; C</div><div class="">infix operator &lt;$&gt; : B</div><div class=""><br class=""></div><div class="">It's already included as an alternate solution.</div></div></div></blockquote><div><br class=""></div><div>Your argument against this in the alternatives is compelling. &nbsp;We should avoid this one.</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><br class=""></div><div class="">2. Limit precedence relationships.</div><div class=""><br class=""></div><div class="">Do we really need a full-blown Directed Acyclic Graph?</div><div class="">Could `above` and `between` be enough?</div></div></div></blockquote><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><br class=""></div><div class="">Example:</div><div class=""><br class=""></div><div class="">precedencegroup B : between(A, C)</div></div></div></blockquote><div><br class=""></div><div>Brainstorming some other options here based on Brent’s syntax</div><div><br class=""></div><div>A list:</div><div>precedence NewGroup &gt; ExistingGroup, &lt; OtherExistingGroup left</div><div><br class=""></div><div>Require braces for multiple precedence levels:</div><div>precedence NewGroup {</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>left</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>&gt; ExistingGroup</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>&lt; OtherExistingGroup</div><div>}</div><div><br class=""></div><div>I think my preference is this “lightweight” braced option when multiple relations are necessary, with Brent’s syntax as a shorthand for the common case.</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><br class=""></div><div class="">This is one of dark places of the proposal, obviously underdiscussed.</div><div class="">Are there practical situations other than `above` and `between`?</div><div class="">Do we really need unlimited relationships per one precedence group?</div></div></div></blockquote><div><br class=""></div><div>I don’t have a concrete example, but those would not allow you to place a group above two unrelated groups. &nbsp;I can’t think of a good reason for this restriction unless there are implementation considerations that make it necessary.</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><br class=""></div><div class="">- Anton</div><div class=""><br class=""></div><div class="">Brent Royal-Gordon wrote:</div><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">I like this proposal, except for the `precedencegroup` syntax, which I think is a bit overwrought. Rather than this proposal's:<br class=""><span class="" style="white-space:pre">        </span>precedencegroup Multiplicative {<br class=""><span class="" style="white-space:pre">                </span>associativity(left)<br class=""><span class="" style="white-space:pre">                </span>precedence(&gt; Additive)<br class=""><span class="" style="white-space:pre">        </span>}&nbsp;<br class="">I would prefer to see:<br class=""><span class="" style="white-space:pre">        </span>precedence Multiplicative &gt; Additive left<br class="">(Or possibly, if the `left` is deemed too inexplicable by itself, `associativity(left)`.) I don't really think the `precedence` keyword or the curly brackets bring much to the declaration, and dropping them allows us to replace the awkward compound `precedencegroup` with the shorter and equally explanatory `precedence`.</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=""></body></html>