[Pitch] Predecessor and successor operators for integers

To clarify Danny's point: in Swift the precedence of << is higher than the precedence of -, so technically speaking you don't need to use parens around 1 << 16. Although this is different compared to other languages like Objective-C, C, C#, Rust, Python, possibly others, making it not immediately obvious for people coming from those, so I admit I also tend to put those redundant parens (1 << 16) - 1.

On the postfix operator: you could certainly implement one yourself and use in your own code base, e.g.:

postfix operator +
postfix operator -

postfix func + <T: BinaryInteger> (v: T) -> T {
    v + 1
}

postfix func - <T: BinaryInteger> (v: T) -> T {
    v - 1
}

it just doesn’t seem valuable enough to be included in the standard library.

4 Likes