Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:68195 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 88819 invoked from network); 19 Jul 2013 10:46:47 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Jul 2013 10:46:47 -0000 Authentication-Results: pb1.pair.com smtp.mail=peter.e.lind@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=peter.e.lind@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.217.180 as permitted sender) X-PHP-List-Original-Sender: peter.e.lind@gmail.com X-Host-Fingerprint: 209.85.217.180 mail-lb0-f180.google.com Received: from [209.85.217.180] ([209.85.217.180:47152] helo=mail-lb0-f180.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 68/E1-13120-51919E15 for ; Fri, 19 Jul 2013 06:46:46 -0400 Received: by mail-lb0-f180.google.com with SMTP id o10so3349462lbi.11 for ; Fri, 19 Jul 2013 03:46:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=IFVGpwjXaq3ygWwVjaJGrRxPNLBXjRAh2WM7+0AbUM0=; b=K2TphgXXlMFqMRjpD14aj3XCB1FFpIGu5IvvZZ+ytgDoFG5rFH6pbS5sxqx9hQ+y/5 bZLU7cZbLn8bTKGk90wuHxVuZqXakazAFQ1gsgAwPhJSgNbwpAOWcrAeFBEhbM8/BVT/ 7WNqW90Ukc/EptAkyVt/6u9Y5CEwOVakID72Z8XcODF0Iix2QppZR2bTblfStuP2150p Jf29+cxgHz5WP2ScLJDNpb3jet9dUvBvXX6HijCG0W0ESX5nd/+i2k484fIun0ABEOLB ZgFJ/aYm/1fAmfLa28xTAn3RCy5LMh4Mm7d8H2ElhcbzNE3KfycxBkNAvKvq0aIFbw5E LrDA== X-Received: by 10.152.21.99 with SMTP id u3mr7298720lae.18.1374230802962; Fri, 19 Jul 2013 03:46:42 -0700 (PDT) MIME-Version: 1.0 Received: by 10.112.169.67 with HTTP; Fri, 19 Jul 2013 03:46:22 -0700 (PDT) In-Reply-To: References: <-6008161650538629327@unknownmsgid> Date: Fri, 19 Jul 2013 12:46:22 +0200 Message-ID: To: Yasuo Ohgaki Cc: Dan Cryer , Mateusz Kocielski , Xinchen Hui , Chris London , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=089e0149397ad99cdd04e1db0a16 Subject: Re: [PHP-DEV] Feature Proposal: Allow letter decrementing From: peter.e.lind@gmail.com (Peter Lind) --089e0149397ad99cdd04e1db0a16 Content-Type: text/plain; charset=UTF-8 On 19 July 2013 12:34, Yasuo Ohgaki wrote: > Hi, > > 2013/7/19 Peter Lind > >> On 19 July 2013 11:18, Dan Cryer wrote: >> >>> What's the intended use case for string increment / decrement? >>> >>> >> Personally, I instantly think of mirroring spreadsheet columns - works >> quite well in that context. >> > > ++/-- 'XYZ00001234' would have use cases. > > >> >> >>> It just seems like madness to me, using mathematical operators with >>> strings, producing seemingly arbitrary results in some circumstances (C -> >>> B -> A -> NULL / False ?). >>> >>> >> Throw a warning and don't decrement A/a any further - that's not >> arbitrary. >> > > -- is more problematic. > --'XYZ0000' would be 'XYZ0000' or 'XYY00000' or 'XYY'? > > php -r '$a = "YZ9"; var_dump(++$a);' gives me ZA0 If php -r '$a = "ZA0"; var_dump(--$a);' doesn't give YZ9 you'll just be left scratching your head. Granted, you might be left scratching your head as to why string incrementing works at all, but that can of worms was opened long ago. It would be better not to change length of string, IMO. > e.g. --'XYZ0000' became 'XYY0000' > > I'd go with --XYZ0000 -> XYY9999 Also, the string length shouldn't factor into it. > All chars would stop decrement at lowest chars of [0-9], [a-z], [A-Z]. > e.g. Lowest value of 'XYZ0000' is 'AAA0000'. > > This is not a symmetric operation of ++, but it's impossible to achieve > symmetric > operation ++/-- on strings anyway. > > Only at the edge case - and I personally can't see why that would mean asymmetric operation in the rest of the cases. -- WWW: plphp.dk / plind.dk CV: careers.stackoverflow.com/peterlind LinkedIn: plind Twitter: kafe15 --089e0149397ad99cdd04e1db0a16--