Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:70619 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 3321 invoked from network); 13 Dec 2013 08:15:10 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Dec 2013 08:15:10 -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.212.52 as permitted sender) X-PHP-List-Original-Sender: tjerk.meesters@gmail.com X-Host-Fingerprint: 209.85.212.52 mail-vb0-f52.google.com Received: from [209.85.212.52] ([209.85.212.52:58447] helo=mail-vb0-f52.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 04/1B-32587-D02CAA25 for ; Fri, 13 Dec 2013 03:15:10 -0500 Received: by mail-vb0-f52.google.com with SMTP id p5so1081036vbn.11 for ; Fri, 13 Dec 2013 00:15:07 -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=L8v2JVQXhaE8BJjHn7/UQwRetyAl22M6dYpi6HVD/L8=; b=Gsvzwn/ccChBh4Npu0gfOEaZRNE0gU0F6oUtSetasl0zP9iDw+IVqbmIqMM/Bvgxxu bk+moZ9m5TMyvc6PpxqGoLzMRJQCS0TzQbcfQ6ZgJqdPWRS+eUzYuBkmw3OQfrqqW56e u93sw/7OqBGPkEsothOvMVtDSfIB1yXKyBYPl6gXnGEaNIj06zPmu/U01w4UnJENPFQg JgD+ub1DzXynP2oScdJNVnDgiPUggk0+gMRQyr0WLXLsDMFx/9xmlRzv5ldQyy3EopVW lBNH1v6pLQg18sHk9zlV2Q+MFIWCtBshjheObXVExEGqAXj2npBk7KWRZ7tW3hb+Yg4M lF5w== MIME-Version: 1.0 X-Received: by 10.52.0.9 with SMTP id 9mr485764vda.47.1386922507676; Fri, 13 Dec 2013 00:15:07 -0800 (PST) Received: by 10.58.128.33 with HTTP; Fri, 13 Dec 2013 00:15:07 -0800 (PST) In-Reply-To: References: <52AA1649.2090601@ajf.me> <52AAA1EA.7030106@marc-bennewitz.de> Date: Fri, 13 Dec 2013 16:15:07 +0800 Message-ID: To: Kris Craig Cc: Marc Bennewitz , PHP internals list Content-Type: multipart/alternative; boundary=e89a8ffba4d966b36904ed660f0a Subject: Re: [PHP-DEV] [PROPOSAL] Alphanumeric decrement From: tjerk.meesters@gmail.com (Tjerk Meesters) --e89a8ffba4d966b36904ed660f0a Content-Type: text/plain; charset=ISO-8859-1 Hi, On Fri, Dec 13, 2013 at 3:09 PM, Kris Craig wrote: > On Thu, Dec 12, 2013 at 9:58 PM, Marc Bennewitz >wrote: > > > Hi > > > > Decrementing "a" to a number isn't a good idea because on incrementing > > again you will increment the number and not go back to "a". > > > > Why not just have "a" decrement to an empty string (i.e. "") and an empty > string increment to "a"? Imagine a scenario in which an empty posted value is assumed to be a number and so ++$x is applied; instead of getting the expected "1" they now get "a" which, after an (int) cast will become 0 .. surprise! Then a decrement on an empty string could trigger > a warning and remain empty. That way, we won't have situations where > decrementing from "a" and incrementing back would output a number. > Actually, the increment of "" is "1", which is still a string; the increment of "1" is int(2), though. That said, isn't it bad enough that php already has exceptions such as: * ++$x is not always the same as $x += 1 * ++false remains false, but ++null becomes int(1) If decrementing strings should work, I would request to also make ++false => true and --true => false Lastly, if I could go back in time I would have created str_inc() and str_dec() so that + has a unambiguous meaning :) > > --Kris > -- -- Tjerk --e89a8ffba4d966b36904ed660f0a--