Re: [PROPOSAL] Alphanumeric decrement

From: Date: Mon, 16 Dec 2013 18:26:20 +0000
Subject: Re: [PROPOSAL] Alphanumeric decrement
References: 1 2 3 4 5 6  Groups: php.internals 
Request: Send a blank email to internals+get-70666@lists.php.net to get a copy of this message
Tjerk Meesters wrote (on 13/12/2013):
Basically it makes the $x++ or ++$x work as if you types $x += 1 or $x = $x + 1 (except for arrays, currently) ++null becomes int(1), --null becomes int(-1)
Yes please! One of my colleagues once raised a bug that currently incrementing null results in 1, but decrementing it results in it remaining null. On the other hand, null -= 1 results in -1 as you would expect. The bug was closed as invalid, stating that this is documented behaviour, but I have never understood why this would be anything other than an accidental side effect of implementation, nor why you would ever rely on it.
++"123a" becomes "123b" but with a notice that string increment is deprecated
Lukewarm on this part; the current syntax seems fairly logical to me, and the proposed new functions more ugly for no very good reason. Regards, -- Rowan Collins [IMSoP]

Thread (22 messages)

« previous php.internals (#70666) next »