[swift-evolution] ++ and --
swift-evolution at haravikk.me
Wed Mar 23 09:09:24 CDT 2016
> On 23 Mar 2016, at 13:33, Ross O'Brien via swift-evolution <swift-evolution at swift.org> wrote:
> I'd be willing to keep "++" and "--" if they stopped having a return type. "x++" is fine; "let y = x++" is where we lose clarity, so I'd much prefer to see that expressed as "let y = x + 1; x++”.
Personally I don’t see the point; ++ and — only really offer an advantage when they’re being used within conditions/expressions, but as you say that’s when they are at their most dangerous. As single line statements they offer no real saving over += 1 or -= 1, while requiring an additional operator covering all the various integer types. By forcing += 1 and -= 1 we also make sure that all assignment operations contain an equals sign, which I think is good for consistency.
For anyone that is desperately attached to using the operator then it’s not hard to add them back in, but I’ve used these for years and have no special fondness for them.
More information about the swift-evolution