Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:71658 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 57361 invoked from network); 28 Jan 2014 06:12:37 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Jan 2014 06:12:37 -0000 Authentication-Results: pb1.pair.com header.from=tjerk.meesters@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=tjerk.meesters@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.128.182 as permitted sender) X-PHP-List-Original-Sender: tjerk.meesters@gmail.com X-Host-Fingerprint: 209.85.128.182 mail-ve0-f182.google.com Received: from [209.85.128.182] ([209.85.128.182:41528] helo=mail-ve0-f182.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 4A/58-01140-45A47E25 for ; Tue, 28 Jan 2014 01:12:37 -0500 Received: by mail-ve0-f182.google.com with SMTP id jy13so4069664veb.41 for ; Mon, 27 Jan 2014 22:12:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=0OEMvFlhvz2trI78WWVRJ81o3lzO7LmbyYdQ+EwJh/w=; b=gMRuBmw39SAelacyb7lobhu8arVC4VzLWforPdHx+WasyVH8XuAVhwT4Meq7GoVVf8 6apPz4v8+bB0WeKws7w0UV5lCN0hw1R46/tKFGPGdaui2ndGU3CEQxpKK3pGD8HZiKFe vKRLNxaICV2mcNKcJJyF0F9bExXDKiHyhUObZp/OLcEPa6/yVlHQ3uUFyImfvUfnTimH QPJFGhTKrUL2ZaluhepA1CJFbVSprq/vMNubgBM3i9NUfZsrUL5zS3iFn4oGTSQCgyC1 1pWfdPtGzxGADUQBI7Y0ld9+kHa9ifwnaL6NX9v4uLcfnj0I+W2qkskJfZZIesENlK4O Ckow== MIME-Version: 1.0 X-Received: by 10.221.34.211 with SMTP id st19mr19074017vcb.5.1390889553374; Mon, 27 Jan 2014 22:12:33 -0800 (PST) Received: by 10.58.133.229 with HTTP; Mon, 27 Jan 2014 22:12:33 -0800 (PST) In-Reply-To: References: <52DDBAE5.2010803@ajf.me> <52E6FD70.4010005@ajf.me> <52E70943.3010700@ajf.me> Date: Tue, 28 Jan 2014 14:12:33 +0800 Message-ID: To: Yasuo Ohgaki Cc: Andrea Faulds , PHP internals Content-Type: multipart/alternative; boundary=001a1136516cc032ab04f101b55e Subject: Re: [PHP-DEV] Re: [VOTE] [RFC] Alphanumeric Decrement From: tjerk.meesters@gmail.com (Tjerk Meesters) --001a1136516cc032ab04f101b55e Content-Type: text/plain; charset=ISO-8859-1 Hi, On Tue, Jan 28, 2014 at 10:51 AM, Yasuo Ohgaki wrote: > Hi Tjerk, > > On Tue, Jan 28, 2014 at 10:39 AM, Tjerk Meesters > 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. > The RFC doesn't mention this, but the intended behaviour is that `$a = true; ++$a;` yields `bool(true)`, i.e. no overflow ... however, I'm open to the suggestion to make it "overflowable", like integer values. Btw, doing flip/flop can be done with `$val = (bool)1 - $val;` as well :) > > Other proposal sounds reasonable to me, too. > > Regards, > > -- > Yasuo Ohgaki > yohgaki@ohgaki.net > -- -- Tjerk --001a1136516cc032ab04f101b55e--