Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:70621 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 10690 invoked from network); 13 Dec 2013 09:37:55 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Dec 2013 09:37:55 -0000 Authentication-Results: pb1.pair.com header.from=yohgaki@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=yohgaki@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.128.43 as permitted sender) X-PHP-List-Original-Sender: yohgaki@gmail.com X-Host-Fingerprint: 209.85.128.43 mail-qe0-f43.google.com Received: from [209.85.128.43] ([209.85.128.43:38224] helo=mail-qe0-f43.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 80/6C-32587-275DAA25 for ; Fri, 13 Dec 2013 04:37:55 -0500 Received: by mail-qe0-f43.google.com with SMTP id 2so1387839qeb.30 for ; Fri, 13 Dec 2013 01:37:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=8KcBqNMphRkNP9CkZL+qBKTyUuhj7IsACS4Kp4McYsc=; b=zLsk186XEIHDTlO+hLU+98LMmD8PX3CVmpCu4IjStWtX56HH/Ib813sXGwxPBU0VpR 5KXRXkR3VeDNOvhNffr0KExdVTOI1rJt/sxxJtdWsCrSV6MGswWqWvHqoHMTEoQb+vcR QaOa24JVcpyhwQXFXVVI3e+GMuQ5JKF8jB2Z4mvOpEzoZQNtfhXsFhX4VeliQFVNu8fq o2I/9VRwzNhC2umATTr0wIVPeWPFxNxDi4l4EchdX1sxklYWmiC7P0vV+xoUHt7Bqv4E i5SNNoI0MHE7m8Y5XUsYou83cyX4X088/I0ZfYtkgSSc5w/cWOrIrb5AaxpIGh64KXDD nOvw== X-Received: by 10.229.249.66 with SMTP id mj2mr2933586qcb.4.1386927472295; Fri, 13 Dec 2013 01:37:52 -0800 (PST) MIME-Version: 1.0 Sender: yohgaki@gmail.com Received: by 10.224.23.129 with HTTP; Fri, 13 Dec 2013 01:37:11 -0800 (PST) In-Reply-To: <52AA1649.2090601@ajf.me> References: <52AA1649.2090601@ajf.me> Date: Fri, 13 Dec 2013 18:37:11 +0900 X-Google-Sender-Auth: hJ3T-0EzxL8xLZABHzP9YjTo_kk Message-ID: To: Andrea Faulds Cc: PHP internals Content-Type: multipart/alternative; boundary=001a1136739a50c3a104ed67377f Subject: Re: [PHP-DEV] [PROPOSAL] Alphanumeric decrement From: yohgaki@ohgaki.net (Yasuo Ohgaki) --001a1136739a50c3a104ed67377f Content-Type: text/plain; charset=UTF-8 Hi Andrea, On Fri, Dec 13, 2013 at 5:02 AM, Andrea Faulds wrote: > At present, it's possible to increment (++) an alphanumeric string, such > that "a" when incremented becomes "b", "z" becomes "aa", and so on. > > However, it's irritated me that the same is not true for the decrement > (--) operator. At present, "aa" when decremented stays as "aa", and "b" > when decremented stays as "b". This lack of symettry is counterintuitive to > me. I don't think it's what you would expect here. > > So I've written a patch which would change this. "aa" when decremented > would be "z", and "b" when decremented would be "a". It also handles > decrementing "a", which becomes "0". This creates an interesting new > asymettry: {$a = "a"; $a--; $a++;} will result in $a being integer 1. I > think it's better than the previous behaviour, though, which resulted in > "b". > > The diff is here: https://github.com/TazeTSchnitzel/php-src/ > compare/php:PHP-5.6...AlphanumericDecrement > > My aim is to try and get this into PHP 5.6, if people are interested. > Thoughts? > Your proposal would be more intuitive than the current behavior in most cases. While a go, I was about to propose similar patch, but I didn't. I think the reason was that I've concluded it is impossible to make string decrements logical anyway. Just my .02c I'll read your patch and may comment if there is something to say. There are users who use string increment now, but I suppose nobody is using string decrements because it's not working as most people expect. Edge case should be considered carefully, since it would cause more confusion than now. Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net --001a1136739a50c3a104ed67377f--