Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:70622 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 13239 invoked from network); 13 Dec 2013 10:02:25 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Dec 2013 10:02:25 -0000 Authentication-Results: pb1.pair.com header.from=tyra3l@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=tyra3l@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.178 as permitted sender) X-PHP-List-Original-Sender: tyra3l@gmail.com X-Host-Fingerprint: 209.85.216.178 mail-qc0-f178.google.com Received: from [209.85.216.178] ([209.85.216.178:39289] helo=mail-qc0-f178.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D0/DC-32587-F2BDAA25 for ; Fri, 13 Dec 2013 05:02:24 -0500 Received: by mail-qc0-f178.google.com with SMTP id i17so1289064qcy.37 for ; Fri, 13 Dec 2013 02:02:21 -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=uOPGUZ6i9/k9r5MGxvTInf7hSAtcPvphLvHfMRntjFo=; b=VF0AqUbIj76gENa0vOsG9b0sJEcKAGDRV1IZzV6JXuOMC/kVdrTKU7Vuu6faaLE/qj u3NT7WK2KhKSbLd3LJJO+oRDijLjUqPX+yS8MKXO7U2tevnc1D1HVFrKFJB5ZRPLKA8T E6yVYsKUFg44N9BVa2yWQNnJiaVLCZFpg7SuK6a1ESifQ1tp7VNEHz0Kg7/MPLhrLe3K S06Cn8fmJcG61cb0kaTij0UOlKlOA0Imm/vRY3+QLlm8kvyNivq4nruf4OqIHCsPHqAI d42GSQneWaD8KjCk9sLeMMMRsC/CTGTPl2UO5tKaqRRn4nvC9YK4J5aNouXN5Vlv57od m4hw== MIME-Version: 1.0 X-Received: by 10.224.151.79 with SMTP id b15mr3126142qaw.46.1386928941034; Fri, 13 Dec 2013 02:02:21 -0800 (PST) Received: by 10.140.37.179 with HTTP; Fri, 13 Dec 2013 02:02:20 -0800 (PST) In-Reply-To: <52AA1649.2090601@ajf.me> References: <52AA1649.2090601@ajf.me> Date: Fri, 13 Dec 2013 11:02:20 +0100 Message-ID: To: Andrea Faulds Cc: PHP internals Content-Type: multipart/alternative; boundary=089e0141a46cdbf40e04ed678e7d Subject: Re: [PHP-DEV] [PROPOSAL] Alphanumeric decrement From: tyra3l@gmail.com (Ferenc Kovacs) --089e0141a46cdbf40e04ed678e7d Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Thu, Dec 12, 2013 at 9:02 PM, Andrea Faulds wrote: > Good evening, > > 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 =3D "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? > > -- > Andrea Faulds > http://ajf.me/ > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > Hi, While I agree that the current implementation is unintuitive, I would be against changing it in a minor version. In this thread multiple people mentioned that it would be ok to change the alpha decrementing, because it wasn't working before and/or nobody would use it as it isn't working currently. I think you misuse the "not working" here. It works (as it doesn't throw an error), but it behaves differently, what you would like/expect to see, and we also have this behavior documented. So changing the behavior in my opinion would be a BC break, and given the nature of this feature, I think that there are no solution, which would eliminate all the edge-cases and make the feature truly consistant/symetric to the current incrementing and to our type juggling, so I think we can't even call it a bugfix(and ship it in a minor), when we change it from mostly-broken to slightly-broken. --=20 Ferenc Kov=C3=A1cs @Tyr43l - http://tyrael.hu --089e0141a46cdbf40e04ed678e7d--