Re: [PROPOSAL] Alphanumeric decrement
| From: | Tjerk Meesters | Date: | Mon, 16 Dec 2013 23:33:16 +0000 |
| Subject: | Re: [PROPOSAL] Alphanumeric decrement | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-70684@lists.php.net to get a copy of this message | ||
On Tue, Dec 17, 2013 at 2:26 AM, Rowan Collins <rowan.collins@gmail.com>wrote:
> 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.
>
I would love to completely eradicate it, but I also realize that there's
existing code using it, such as:
for ($class = 'A1'; $class <= 'A4'; ++$class);
It might be hard to find the places where such code is being used, so I
figured it made sense to have a deprecation period instead.
>
> Regards,
> --
> Rowan Collins
> [IMSoP]
>
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
--
Tjerk