[swift-evolution] Improvement proposal: change overflow behavior in successor()/predecessor() methods for Int types

Vladimir.S svabox at gmail.com
Fri Apr 8 05:49:50 CDT 2016

On 07.04.2016 21:43, Dmitri Gribenko wrote:
> There would be no need to.  Collection will have a .successor(of:)
> method that returns the next index after the given one.

I see. Thank you for letting know about this.

> I can see that, but when you know that you are dealing with an
> integer, isn't "+ 1" a more common and readable notation?

Hmm.. I believe that i++ is muuuch common used than i += 1 ;-)

Personally I totally agree with almost all reasons why we should drop these 
++/--, but until this moment I was not agree that operator(not expression) 
i++ (i.e. operator to increase i to 1 that do not return any value) 
produces any problem in code. And it is so common in programming word, in 
c/c++ which we will(!) use with our Swift code often, so it can't produce 
any misunderstanding like "what does this "i++" line do??"
(again, just operator, like: if something { someInt++ } )

But now, I was pointed that someInt += 1 is better because of this "=" char 
in operator i.e. we clearly say that we will assign the value to variable, 
mutate it.
And I think this makes the language better, so right now I fully support 
the decision to remove ++/--

So.. Thank you for your time and your replies :-)


More information about the swift-evolution mailing list