[swift-evolution] Reconsider ++ and -- operators removal and prevent other well-known operators from change
willstanton1 at yahoo.com
Sat Jan 30 13:05:27 CST 2016
I think Van made good points about readability, and I do not recall the retention of ‘++’ and ‘--’ being discussed much (perhaps since SE-0004 and 0007 were accepted). So in case it’s up for discussion:
At first, I really disliked the removal of ++ and --. In my opinion, the first three disadvantages in SE-0004 (https://github.com/apple/swift-evolution/blob/master/proposals/0004-remove-pre-post-inc-decrement.md) were not that strong:
> These operators increase the burden to learn Swift as a first programming language - or any other case where you don't already know these operators from a different language.
‘++’ does not seem less obvious than ‘+=’ and learning about the 2-4 extra operators doesn’t seem burdensome.
++ and -- are also not particularly rare (I remember being surprised that Python did not support them)
> Their expressive advantage is minimal - x++ is not much shorter than x += 1.
Still, `++` is easier to type than `+= 1`
> Swift already deviates from C in that the =, += and other assignment-like operations returns Void (for a number of reasons). These operators are inconsistent with that model.
I liked the alternative considered: keep ++ and -- while returning void
But I became less bothered by the proposal, since I agreed with this:
> Swift has powerful features that eliminate many of the common reasons you'd use ++i in a C-style for loop in other languages, so these are relatively infrequently used in well-written Swift code. These features include the for-in loop, ranges, enumerate, map, etc.
So, I respectfully disagree with removing the operators, but I also don’t have strong objections (as I first thought I might).
> On Jan 30, 2016, at 1:12 PM, Vanderlei Martinelli via swift-evolution <swift-evolution at swift.org> wrote:
> Hello everybody.
> I see Swift as a member of “C family" (a granddaughter/grandson of C, a daughter/son of Objective-C). OK, she/he is different and has her/his own personality like a daughter/son should be and have, but I still like to see Swift and recognize some traces that I know are things that became from C.
> This said, I would like to say that after the removal of `++` and `--` my code becomes less readable and more prone to errors. There were two characters to differentiate an addition from a subtraction, now there is only one (`+= 1`, `-= 1`). Also the character keys are very close in the US keyboard so it is easier to make a mistake and is not as simple as the previous solution when I typed two times the same key. Using Erica's way of saying certain things: I do not love the removal of `++` and `--`.
> I do not know how far the Swift is to the adolescence, but it is certain that teenagers are rebels. There's something very good at it. In most cases they are to be certain. But in some things they regret later. Now I see that many of us want to replace the `??` operator to something else. I'm wondering the next steps... To replace the `&&`, `||` and `!` operator with `and`, `or`, `not`? I’m not "loving" this as well.
> Are these changes really necessary for the Swift evolution? Is it the better path to deny its origin and to try to fix what is not broken? I would like you to think about it.
> There are many other things that really need to be improved and repaired and other things needed to are created. Those mentioned here in this message does not seem to fit it.
More information about the swift-evolution