Remove the ++ and –- operators
51–60 of 249 posts
Re: Remove the ++ and –- operators
#52Demand X = X + 1. For clarity/readability/formatting.
Re: Remove the ++ and –- operators
#53 for (i=0;i
any more.Re: Remove the ++ and –- operators
#54Earlier quoted context omitted.
Agreed. In the list of disadvantages, we don't see "many professional programmers expect the ++ and -- operator" or "beginners will be confused because old code examples on the web will stop working".
This argument feels like 'legacy for legacy's sake'.
Re: Remove the ++ and –- operators
#55I strongly disagree with this. Being able to do a very simple task like increment or decrement a number inline is useful and reduces clutter and I've always found the idea that the operator complicates things ridiculous. The way they work has always been obvious to me since I first learned to program in PHP as a tween.
"These operators increase the burden to learn Swift as a first programming language" It looks like they may be trying to make it easier for current tweens that would have otherwise learned PHP. Don't see the value in this. These operators are terse, well known, and are implemented in a wide array of languages.
Re: Remove the ++ and –- operators
#56Re: Remove the ++ and –- operators
#57Removing ++ et al: ok, they have their problems. But retaining x += 1? That one has always annoyed me. Why does '+' (and friends) get this special form, but not my functions? Just because they're built-in. They are useful; no argument there. Largely because 'x' can be a complex reference, and you don't have to type it twice (and the compiler doesn't have to figure out that its the same expression twice). E.g. x=x+1 i…
Your functions can get that (and other) special form. You need to use a language where you can define your own operators. Have you looked at C++, C#, Haskell, or LISP?
Re: Remove the ++ and –- operators
#58I strongly disagree with this. Being able to do a very simple task like increment or decrement a number inline is useful and reduces clutter and I've always found the idea that the operator complicates things ridiculous. The way they work has always been obvious to me since I first learned to program in PHP as a tween.
"These operators increase the burden to learn Swift as a first programming language" It looks like they may be trying to make it easier for current tweens that would have otherwise learned PHP. Don't see the value in this. These operators are terse, well known, and are implemented in a wide array of languages.
"plus plus" doesn't mean anything. It might even be confusing that it doesn't add 2.
Re: Remove the ++ and –- operators
#59Why remove x++ and not x += 1? Demand X = X + 1. For clarity/readability/formatting.
A key part of the reason for removing the ++/-- set of operators seems to be that they conflict with Swift's pattern of mutating operators returning void. (An alternative offered was revising them so that they followed that pattern.)
+=/-=, like simple assignment, do not have that problem.
Re: Remove the ++ and –- operators
#60Removing ++ et al: ok, they have their problems. But retaining x += 1? That one has always annoyed me. Why does '+' (and friends) get this special form, but not my functions? Just because they're built-in. They are useful; no argument there. Largely because 'x' can be a complex reference, and you don't have to type it twice (and the compiler doesn't have to figure out that its the same expression twice). E.g. x=x+1 i…
x = + 1;
It could then get arbitrarily complex. E.g. x = ( + 1) / atan() - ;
and no matter how complex 'x' was in practice, the compiler (and the code reader) could keep track of what was happening.