Re: Re: [VOTE] [RFC] Alphanumeric Decrement
| From: | Yasuo Ohgaki | Date: | Tue, 28 Jan 2014 02:51:20 +0000 |
| Subject: | Re: Re: [VOTE] [RFC] Alphanumeric Decrement | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-71657@lists.php.net to get a copy of this message | ||
Hi Tjerk,
On Tue, Jan 28, 2014 at 10:39 AM, Tjerk Meesters
<tjerk.meesters@gmail.com>wrote:
> I still have an RFC lying around that suggests this, together with some
> other changes to how increment / decrement works. Perhaps we could flesh
> this out further?
>
> https://wiki.php.net/rfc/normalize_inc_dec
>
The following behaviour is proposed:
// booleans
$a = false; ++$a; // bool(true)
$a = true; --$a; // bool(false)
// null values
$a = null; --$a; // null
$a = null; ++$a; // null
// empty strings
$a = ''; ++$a; // int(1)
// non-numeric strings
$a = '12d9';
++$a; // string(4) "12e0" + Notice: String increment is deprecated, use
str_inc() instead in php shell code on line 1
++$a; // float(13)
+1 especially boolean++/--.
It's great for flip flop. I guess most users use int++ and int%2 for flip
flop currently.
Existing scripts using ++/-- against bool would be a bug most likely.
Other proposal sounds reasonable to me, too.
Regards,
--
Yasuo Ohgaki
yohgaki@ohgaki.net