Re: [RFC] Path to Saner Increment/Decrement operators
| From: | Mark Baker | Date: | Thu, 19 Jan 2023 00:23:48 +0000 |
| Subject: | Re: [RFC] Path to Saner Increment/Decrement operators | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-119340@lists.php.net to get a copy of this message | ||
On 18/01/2023 21:25, G. P. B. 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. 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. -- Mark BakerI would like to start the discussion on the Path to Saner Increment/Decrement operators RFC: https://wiki.php.net/rfc/saner-inc-dec-operators The goal of this RFC is to reduce language complexity by making $v++ behave like $v += 1 and $v-- behave like $v -= 1;If that is the goal, then I would agree with this RFC. However, changing the PERL string increment feature does not IMO fit into that goal, and it also a useful*feature*. On that base I would vote against this. And I suspect many others would as well.