<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div><div>I think there's something to this, but I'd prefer it look a bit more like what happened in SE-40 (<span style="background-color: rgba(255, 255, 255, 0);"><a href="https://github.com/apple/swift-evolution/blob/714dd43863775705cebc77574287ab0974bfa615/proposals/0040-attributecolons.md">https://github.com/apple/swift-evolution/blob/714dd43863775705cebc77574287ab0974bfa615/proposals/0040-attributecolons.md</a></span>) so 'associativity' and 'precedence' are made to look more compiler-construct-y.</div><div><br></div><div><div><font color="#000000"><span style="background-color: rgba(255, 255, 255, 0);">infix operator <> { </span></font></div><div><font color="#000000"><span style="background-color: rgba(255, 255, 255, 0);"> @associativity(left)</span></font></div><div><span style="background-color: rgba(255, 255, 255, 0);"> @precedence(100)</span></div><div>}</div></div><div><br></div><div>As for assignment operators, if memory serves syntax for them was quickly deprecated because they can be subsumed by making the LHS of an infix operator inout. I'm not sure there needs to be much more at the declaration site than that.</div><br>~Robert Widmann</div><div><br>2016/03/05 21:54、Kevin Lundberg via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> のメッセージ:<br><br></div><blockquote type="cite"><div><span>Ever since Swift 1.0 I've found the infix operator attribute syntax strange:</span><br><span></span><br><span>infix operator <> { associativity left precedence 100 }</span><br><span></span><br><span>The value of the attribute has no visual cue that ties it to the name of</span><br><span>the attribute. One could arguably read left as its own attribute name</span><br><span>rather than the value set to the associativity attribute, or could read</span><br><span>the wrong pair as one attribute, like "left precedence".</span><br><span></span><br><span>In the spirit of Erica Sadun's recent proposal to make attribute syntax</span><br><span>uniform by using : over =, I'd like to see operator declaration syntax</span><br><span>follow a similar structure:</span><br><span></span><br><span>infix operator <> { associativity: left, precedence: 100 }</span><br><span></span><br><span>In my opinion, this simple change makes operator attributes much more</span><br><span>readable. This also should help future proof readability in operator</span><br><span>attributes if operators gain more of them in the future. A longer list</span><br><span>of attributes with the current syntax would become much harder to read.</span><br><span></span><br><span>The only (minor) sticking point I've noticed is the assignment attribute</span><br><span>in the standard library:</span><br><span><a href="https://github.com/apple/swift/blob/12b793c87f160a0f18bb8762e425174205c5d80a/stdlib/public/core/Policy.swift#L427">https://github.com/apple/swift/blob/12b793c87f160a0f18bb8762e425174205c5d80a/stdlib/public/core/Policy.swift#L427</a>.</span><br><span>This attribute isn't documented in TSPL and it has no value associated</span><br><span>with it. Since user-defined operators are not meant to be assignment</span><br><span>operators, it may not matter much how these are represented, but</span><br><span>ostensibly some user-defined attribute that has no value may come about</span><br><span>in the future. We could make these attributes simply look like this:</span><br><span></span><br><span>infixoperator+={ associativity:right,precedence: 90,assignment }</span><br><span></span><br><span>or perhaps we could make it so that this attribute must now have a</span><br><span>Boolean value that defaults to false if it isn't provided:</span><br><span></span><br><span>infixoperator+={ associativity:right,precedence: 90,assignment: true }</span><br><span></span><br><span>Any thoughts?</span><br><span></span><br><span>- Kevin</span><br><span>_______________________________________________</span><br><span>swift-evolution mailing list</span><br><span><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br></div></blockquote></body></html>