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

Patrick Schluter Patrick.Schluter at bbox.fr
Tue Mar 24 14:29:40 UTC 2026


On Sunday, 8 March 2026 at 10:26:54 UTC, claptrap wrote:
> On Sunday, 8 March 2026 at 10:16:56 UTC, user1234 wrote:
>> On Sunday, 8 March 2026 at 03:30:55 UTC, claptrap wrote:
>>> [...]
>>> Just seems like p++ should behave like p+=N for parameters, I 
>>> mean if you had never seen that syntax before you would 
>>> probably assume similar behaviour.
>>
>> 1. This would break code
>
> agreed
>
>> 2. that would be inconsistent with the C version
>
> agreed
>
>> 3. that would be globally inconsistent with the definition, 
>> that can be reduced to "return the value of the sub-expression 
>> before the side-effect".
>
> Doesnt that mean "p++" is inconsistent? Arn't "p++" and "p+=1" 
> essentially shorthand for "p=p+1"

NO. p++ is shorthand for (){ auto temp=p; p+=1; return temp }


More information about the Digitalmars-d mailing list