[swift-evolution] [Proposal] Custom operators

Ben Rimmington me at benrimmington.com
Sun Apr 3 13:41:00 CDT 2016


<https://github.com/Anton3/swift-evolution/blob/operator-precedence/proposals/
NNNN-operator-precedence.md>

Another way to eliminate numerical precedence is by using keywords:

infix operator << {
    associativity none
    exponentiative
}

infix operator * {
    associativity left
    multiplicative
}

infix operator + {
    associativity left
    additive
}

infix operator == {
    associativity none
    comparative
}

infix operator += {
    associativity right
    assignment
}

All operators would need to use one of the existing precedence groups (Table 2):

<https://developer.apple.com/library/ios/documentation/Swift/Reference/
Swift_StandardLibrary_Operators/>

-- Ben



More information about the swift-evolution mailing list