On 19.01.2023 at 01:23, Mark Baker wrote:

> However, the ++ and -- are the "Increment" and "Decrement" operators,
> not the Add1 and Subtract1 operators; while they behave in that way when
> used with variables containing numeric values, they are special
> operators and not simply a syntactic sugar for +=1 and -=1. As long as
> their behaviour is consistent, and definition of what "Increment" and
> "Decrement" mean is clearly defined for different datatypes, then I feel
> that the PERL-style alpha string increment has enough valid use cases to
> justify itself.

I understand your point, but also understand why increment/decrement
operations can be seen as adding/subtracting 1 (the current
documentation is actually pretty close to that interpretation).  I'm not
sure which interpretation I'd prefer.

> We might also discuss consistency of datatype changes when these
> operators are used.
>
> $a = PHP_INT_MAX;
>
> ++$a;
>
> or
>
> $a = '10';
>
> ++$a;
>
> both change the datatype of $a; which isn't documented behaviour either.

Well, that is the usual type juggling, but is indeed not properly
document, from what I can tell (the "type juggling" page doesn't mention
increment/decrement, and the "incrementing/decrementing operators" page
doesn't mention the type juggling).

--
Christoph M. Becker

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to