Restricting ++ and --
Lutger
lutger.blijdestijn at gmail.com
Sun Oct 25 06:39:02 PDT 2009
bearophile wrote:
> This post is born from a bug I've just removed.
> In the past I have read more than one C coding standard (or better, lists
> of coding tips) that warn against bugs caused by ++ and --. They suggest
> to not use them compound in expressions. They allow to use them when alone
> on an instruction.
>
> Python designers have totally avoided to put those operators in the
> language, with the rationale they are bug-prone while saving just a little
> of typing.
>
> Removing those operators from D, as Python, may look excessive. So a
> possible compromise can be:
> - Deprecate the pre versions: --x and ++x
> - Make them return void, so they can't be used as expressions like this:
> y = x++;
> foo(x--);
> You have to use them as:
> x++; y = x;
> x--; foo(x);
> (So ++ and -- become similar to the Inc() and Dec() functions of Pascal).
>
> What problems such changes may cause?
>
> Bye,
> bearophile
It is way too patronizing. These operators are very well known by people
with a C background and actually quite elegant if you are used to reading
them, imho.
More information about the Digitalmars-d
mailing list