Re: [PHP-DEV] Allow null variables to be decremented

2020-02-19 Thread Rowan Tommins
On Wed, 19 Feb 2020 at 15:05, Côme Chilliet < come.chill...@fusiondirectory.org> wrote: > > Is ++$a behaving differently than $a++ for NULL/FALSE/TRUE? > The actual implementation of incrementing and decrementing is the same whichever operator you use, it's just wrapped in code to return the old

Re: [PHP-DEV] Allow null variables to be decremented

2020-02-19 Thread Côme Chilliet
Le mercredi 19 février 2020, 15:59:24 CET Christian Schneider a écrit : > Am 19.02.2020 um 15:52 schrieb Côme Chilliet > : > > Is there any reason the engine is not running the same code or even > > compiling to the same opcodes $a++ and $a+=1? > > If it should never differ, why is it not the sam

Re: [PHP-DEV] Allow null variables to be decremented

2020-02-19 Thread Christian Schneider
Am 19.02.2020 um 15:52 schrieb Côme Chilliet : > Le mardi 18 février 2020, 20:27:37 CET Rowan Tommins a écrit : >> With booleans, there is at least a consistency between those two >> operators, even though it's consistently weird. There's definitely a >> strong case for making them match +=1 and

Re: [PHP-DEV] Allow null variables to be decremented

2020-02-19 Thread Côme Chilliet
Le mardi 18 février 2020, 20:27:37 CET Rowan Tommins a écrit : > With booleans, there is at least a consistency between those two > operators, even though it's consistently weird. There's definitely a > strong case for making them match +=1 and -=1 though. Is there any reason the engine is not r

Re: [PHP-DEV] Allow null variables to be decremented

2020-02-18 Thread Rowan Tommins
On 18/02/2020 14:00, Nikita Popov wrote: Principally in favor of this change, I do think that ++ and -- should behave consistently if nothing else. We might want to consider giving the same treatment to false/true as well, which should be interpreted as 0/1. That is $foo++ / $foo-- should behav

Re: [PHP-DEV] Allow null variables to be decremented

2020-02-18 Thread Nikita Popov
On Sat, Feb 15, 2020 at 6:44 PM Rowan Tommins wrote: > Hi all, > > There is currently an odd inconsistency when using the decrement > operator on a null variable: > > $a = null; $a=$a+1; // int(1) > $a = null; $a+=1; // int(1) > $a = null; ++$a; // int(1) > > $a = null; $a=$a-1; // int(-1) > $a =

Re: [PHP-DEV] Allow null variables to be decremented

2020-02-17 Thread Christian Schneider
Am 15.02.2020 um 19:21 schrieb Mark Randall : > That incrementing a null works at all is a painful part of the language spec > that I would argue needs flushing down the toilet, rather than further > reinforcing. Just for the record: There is no agreement on that. And while a lot of people on in

Re: [PHP-DEV] Allow null variables to be decremented

2020-02-15 Thread Rowan Tommins
On 15/02/2020 18:21, Mark Randall wrote: I'm not so sure... That incrementing a null works at all is a painful part of the language spec that I would argue needs flushing down the toilet, rather than further reinforcing. The problem then is, where do you stop? There are dozens of places wh

Re: [PHP-DEV] Allow null variables to be decremented

2020-02-15 Thread Rowan Tommins
On 15/02/2020 18:11, tyson andre wrote: My opinion is that it'd be more consistent for `--` to work like `-= 1` (e.g. become `-1`). It might break some code, but that code was probably incorrect. Yep, this is precisely the way I see it. -- Rowan Tommins (né Collins) [IMSoP] -- PHP Internal

Re: [PHP-DEV] Allow null variables to be decremented

2020-02-15 Thread tyson andre
My opinion is that it'd be more consistent for `--` to work like `-= 1` (e.g. become `-1`). It might break some code, but that code was probably incorrect. Out of scope of the proposed RFC, but this reminds me of a similar issue: Currently, the `++` and `--` operators do nothing to arrays or obje

[PHP-DEV] Allow null variables to be decremented

2020-02-15 Thread Rowan Tommins
Hi all, There is currently an odd inconsistency when using the decrement operator on a null variable: $a = null; $a=$a+1; // int(1) $a = null; $a+=1; // int(1) $a = null; ++$a; // int(1) $a = null; $a=$a-1; // int(-1) $a = null; $a-=1; // int(-1) $a = null; --$a; // null I would like to prop