[swift-evolution] Proposal: change infix operator attributes syntax to be more consistent with the rest of the language

Brent Royal-Gordon brent at architechies.com
Sat Mar 5 23:24:04 CST 2016


> infix operator += { associativity: right, precedence: 90, assignment: true }

I'm a little uncomfortable putting what looks for all the world like a parameter list into curly brackets; it just doesn't feel in step with other declarations. (To be fair, I wasn't comfortable with the old way, either.)

Here's what I suggest. Usually, a bunch of parameters modifying a declaration would go in a parenthesized list after the particular keyword they modified, and in this case, `associativity` and `precedence` (and probably `assignment` too, though I don't know for sure since it's not documented) are only valid on an infix operator. That would suggest:

	infix(associativity: right, precedence: 90, assignment) operator +=
	prefix operator -
	postfix operator !

-- 
Brent Royal-Gordon
Architechies



More information about the swift-evolution mailing list