4 ms·
Imagine Ritchie & Thompson would have taken the above advice and named ++ operator "increment(x)". That would suck in a big way.
by rumcajz 11y ago
Imagine Ritchie & Thompson would have taken the above advice and named ++ operator "increment(x)".
That would suck in a big way.
- jacquesm 11y agoI know you jest but I can actually see some advantages to not even having a ++ (and a --) operator. You already have '+1' and '-1' so it's not even shorter (and those can't be sneakily inserted into expressions leading to side effects of the expression other than the value computed) and the post and pre-decrement versions of that can lead to very subtle bugs.
- icebraining 11y agoIt's shorter because with +1 you need to write the variable twice. That said, I do prefer Python's += operator over ++.
- deleted 11y ago[deleted]
- hollerith 11y agoSomeone reading your comment might be left with the false impression that C does not have the += operator.
- icebraining 11y agoFair enough, I meant Python uses += in lieu of ++, since it doesn't have the latter.