Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:68193 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 85817 invoked from network); 19 Jul 2013 10:39:05 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Jul 2013 10:39:05 -0000 Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.182 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.214.182 mail-ob0-f182.google.com Received: from [209.85.214.182] ([209.85.214.182:53974] helo=mail-ob0-f182.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2E/31-13120-84719E15 for ; Fri, 19 Jul 2013 06:39:05 -0400 Received: by mail-ob0-f182.google.com with SMTP id va7so5136129obc.13 for ; Fri, 19 Jul 2013 03:39:02 -0700 (PDT) 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=FgS8oUD+d3kO9apMFllbOD1actD61giXqNBrJsgy1Ok=; b=z1er5ZbOJiGNEgxcbjgHxjMB+nUVZz4IqU8mqd7H2wjgvRxlXeRpndSrxE6zXpLfMg L9aI58E3qCo/2tqfIUWJSMqpS1xsEEqrirY7N0NITd7KZWuQq27bVcjf8ESFJfeyFSak Sqp5bavtU3HpFQw+UaSMb/ZIF7d2YgqH2q5iF9A4q7C6+ahrs9McxwYWAM1/mUx8GHLS JXrbRY0KElc9LuBRxoqSfvUnqMwdO0911UAUnDyu2597yqAi7j32LfefQVvk7p5kwDgL OZBJQUKX6q9yOEalm8t44BdsDm76a59V4foOQARqfZ1fqvWE1BNdr8piBZ4x/ZmW12dq eIHA== MIME-Version: 1.0 X-Received: by 10.182.148.100 with SMTP id tr4mr11466138obb.53.1374230342642; Fri, 19 Jul 2013 03:39:02 -0700 (PDT) Received: by 10.182.89.170 with HTTP; Fri, 19 Jul 2013 03:39:02 -0700 (PDT) In-Reply-To: References: Date: Fri, 19 Jul 2013 12:39:02 +0200 Message-ID: To: Chris London Cc: PHP internals Content-Type: multipart/alternative; boundary=089e0122ac8069b24204e1daef58 Subject: Re: [PHP-DEV] Feature Proposal: Allow letter decrementing From: nikita.ppv@gmail.com (Nikita Popov) --089e0122ac8069b24204e1daef58 Content-Type: text/plain; charset=ISO-8859-1 On Thu, Jul 18, 2013 at 3:46 PM, Chris London wrote: > My friend shared some code with me today that wasn't working for him. He > was incrementing letters like this: > > $letter = 'A'; > echo ++$letter; // Output: B > > He was then trying to decrement letters like this: > > $letter = 'B'; > echo --$letter; // Output: B > > He was really confused why his code wasn't working. Obviously the answer > is, PHP doesn't support decrementing letters. > > My question is, why specifically doesn't it? > > 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 > I don't think we should add string decrementing due to the rather complex logic behind it (imho the string incrementing that we have shouldn't be there either). What we *should* add though is a notice or warning in case an increment/decrement operation fails. incdec is one of the few places where we currently silently ignore FAILUREs, instead of throwing some helpful error message :) Nikita --089e0122ac8069b24204e1daef58--