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

Erica Sadun erica at ericasadun.com
Sat Mar 5 23:35:13 CST 2016

I like this approach too BUT my only concern is how long it takes to get to the actual name. 
I know I probably hate this already (give me time to sleep on it) and I'm not wedded to the 
approach, but I'd like to see the operator move left for readability so that it's more like a 
func declaration:

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

-- E

> On Mar 5, 2016, at 10:24 PM, Brent Royal-Gordon via swift-evolution <swift-evolution at swift.org> wrote:
>> 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
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160305/7fe63914/attachment.html>

More information about the swift-evolution mailing list