"++" vs "+=" on function parameter

Dom Disc dominikus at scherkl.de
Thu Mar 26 09:25:06 UTC 2026


On Sunday, 8 March 2026 at 02:28:31 UTC, claptrap wrote:
> ++
> inside foo : 0
> after foo : 1
> +=1
> inside foo : 1
> after foo : 1
>
> seems inconsistent to me

No.
We have x++ and ++x, which do different things (post increment 
and pre increment).
++x is equivalent to x += 1. So pure logic requires that x++ 
cannot be equivalent to x += 1. (And semantics says also it 
should not).

This is the funny part of the name C++
It means literally it's the same as C, the value is only 
incremented after use :-)
++C would have been a better name.


More information about the Digitalmars-d mailing list