Restricting ++ and --

Kagamin spam at here.lot
Mon Oct 26 01:38:23 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
> - 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);

int PreInc(ref int i){ i++; return i; }
int PostInc(ref int i){ i++; return i-1; }
y=PreInc(i);
y=PostInc(i);

just a little more difficult.

y=x=0;
Ever wondered what opAssign returns?



More information about the Digitalmars-d mailing list