From: Niklas Frykholm Date: 2001-08-24T06:12:34+09:00 Subject: [ruby-talk:20208] Re: ++ Operator On Fri, Aug 24, 2001 at 05:38:25AM +0900, Lars Christensen wrote: > += should be a method, not an operator. It modifies the object using > addition or appending. Lot of methods in ruby already modify their object. I could live with this. > ++a and a++ are also operators perhaps mapped to methods such as > Numeric#++ and Numeric#++@, and having C semantics. They also modify the > object (and return the value after or before). But not this. There are many good reasons for avoiding ++ operators (1) x+=1 is only 1 character more. (2) In C, x+=1 is a very common operation. In Ruby it is not common at all. Loops over integers are written using functions such as #times and #upto. Thus, since this operation is not particularily common -- why should we have a special case for it? (3) The difference between x++ and ++x is very complicated to explain to beginning programmers and code making use of this difference is usually unreadable. (4) ++ and -- are only "natural" to C (and C-derivate) programmers. To others, it means more syntax to learn and harder to read programs. (5) There is no performance gain (compared to a += that is implemented in place). (6) They complicate the parser. (7) ++ is less general than +=, for example, it is hard to give a sane definition of m++ where m is a matrix. // Niklas