Restricting ++ and --

Rainer Deyke rainerd at eldwood.com
Sun Oct 25 12:26:40 PDT 2009


bearophile wrote:
> Removing those operators from D, as Python, may look excessive. So a
> possible compromise can be: - Deprecate the pre versions:  --x  and
> ++x

There is nothing wrong with the prefix versions.  '--x' is the
equivalent of 'x -= 1', but with less excessive typing.  Any confusing
expression using prefix ++/-- will be just as confusing if rewritten to
use +=/-=.

On the other hand, there are two things wrong with the post versions:
  - They use postfix notation, unlike all other unary operators in D.
  - They have confusion semantics.

I don't use postfix ++/--.  I wouldn't mind if they were removed
entirely.  However, the prefix versions should be kept, and allowed in
compound expressions.


-- 
Rainer Deyke - rainerd at eldwood.com



More information about the Digitalmars-d mailing list