Re: Feature Proposal: Allow letter decrementing
| From: | Chris London | Date: | Thu, 18 Jul 2013 19:22:49 +0000 |
| Subject: | Re: Feature Proposal: Allow letter decrementing | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-68167@lists.php.net to get a copy of this message | ||
The one caveat about decrementing "A" and it goes to NULL is that if you
increment NULL it goes to 1 so that may be confusing. We could also
decrement "A" and it goes to FALSE and FALSE++ is still FALSE
On Thu, Jul 18, 2013 at 1:10 PM, Phil Sturgeon <email@philsturgeon.co.uk>wrote:
> Incrementing "Z" results in "AA", because we're starting again.
> Decrementing "A" should probably go to NULL as -A is no good.
>
> --
> Phil Sturgeon
>
> On Thursday, July 18, 2013 at 3:08 PM, Martin Amps wrote:
>
> One hiccup. I imagine maybe the reason we don't support decrementing is
> because what would happen if you tried to decrement 'A'. In that case I
> would suggest either returning NULL or throwing a notice.
>
>
> It would make sense to make it stay as ‘A’ like incrementing ‘Z' stays as
> ‘Z’.
>
> I do agree that string manipulation with arithmetic operators needs
> work/clarification.
>
> On Jul 18, 2013, at 7:37 AM, Xinchen Hui <laruence@gmail.com> wrote:
>
> 在 2013-7-18,22:31,Mateusz Kocielski <shm@digitalsun.pl> 写道:
>
> It seems logical that if we support increment we should support decrement..
>
>
> My proposal:
>
>
> 1) Support decrementing letters
>
> - or -
>
> 2) Throw a notice explaining that decrementing is not supported so
>
> developers quickly know they can't do that
>
>
> One hiccup. I imagine maybe the reason we don't support decrementing is
>
> because what would happen if you tried to decrement 'A'. In that case I
>
> would suggest either returning NULL or throwing a notice.
>
>
> Thanks for the input
>
>
> Chris London
>
>
> Hello,
>
> Does anybody understand the rules behind the string incrementation? What's
> the explanation of following behaviour?
>
> '$x="ZZ";$x++;var_dump($x);' returns string(3) "AAA"
> '$x=" ZZ";$x++;var_dump($x);' returns string(3) " AA"
>
> see
> http://www.php.net/manual/en/language.operators.increment.php
>
> thanks
>
> Regards,
> Mateusz Kocielski
>
>
>