Restricting ++ and --
d-noob
doesnt at exist.com
Sun Oct 25 04:09:51 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?
Apparently you want to change postInc/Dec to be statements to prevent them from returning values (otherwise the expr semantics would need a special case). That would break C compatibility and sounds ridiculous.
More information about the Digitalmars-d
mailing list