Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:119330 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 99472 invoked from network); 18 Jan 2023 19:43:47 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 18 Jan 2023 19:43:47 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 24F2718050B for ; Wed, 18 Jan 2023 11:43:46 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS20857 136.144.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from outbound5.mail.transip.nl (outbound5.mail.transip.nl [136.144.136.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 18 Jan 2023 11:43:45 -0800 (PST) Received: from submission15.mail.transip.nl (unknown [10.103.8.166]) by outbound5.mail.transip.nl (Postfix) with ESMTP id 4Nxx5W697qzHXBZ for ; Wed, 18 Jan 2023 20:43:43 +0100 (CET) Received: from [IPV6:2a02:a450:3eae:1:3c1a:2c3a:1b1:d24c] (2a02-a450-3eae-1-3c1a-2c3a-1b1-d24c.fixed6.kpn.net [IPv6:2a02:a450:3eae:1:3c1a:2c3a:1b1:d24c]) by submission15.mail.transip.nl (Postfix) with ESMTPA id 4Nxx5R4ZvKz3wZC for ; Wed, 18 Jan 2023 20:43:39 +0100 (CET) Message-ID: <152c67fc-e509-31ad-e8b0-d42572a09e0e@demon-angel.eu> Date: Wed, 18 Jan 2023 20:43:39 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Content-Language: nl To: internals@lists.php.net References: <04288995-54CE-41A4-BFFD-A7CF72F16D3F@gmail.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: ClueGetter at submission15.mail.transip.nl DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=transip-a; d=demon-angel.eu; t=1674071019; h=from:subject:to: references:in-reply-to:date:mime-version:content-type; bh=X1H+cYeQ97LVA8eGWT3IoQNZ2j5R0W/k1hSqvQwGatI=; b=tA01yJbaoAiRCqEeWmeURGyHGt9ZvO8BJQaMslHq/YvEQ/qkbI22AZrrrJaUqJp6ivi6df CW7SxBg7gC4v54x/rSVfxI9o0KC1lWAyvLDPUxAHzfhIHxD6YE+fgNSLkWn4VR+WEv0IIi TT+tFq4aWelHvOYNIt6ZPz9Jms+Th6QpqO9pNzNYbG9qR6QSrKYOa8Uk441ghuIW5ukQP5 1H7wxefHZy8CN6ScwwScygS3uinXejybqFyVd2dAR6/jnk9VKZyy4vKn8jT5t9yVfZo4JY w4Ua5b52CgpfSF4Mm244TIRyoy75Db1z4Lb2B4fsEl9rS/bdh+p3e3jbnk4k7A== X-Report-Abuse-To: abuse@transip.nl Subject: Re: [PHP-DEV] [RFC] Path to Saner Increment/Decrement operators From: mark@demon-angel.eu (Mark Baker) On 18/01/2023 18:27, Kamil Tekiela wrote: > When I read the RFC I was a little sceptical about the deprecation of > string increment functionality. It's something I used in the past and I see > no easy upgrade path. However, after reading this thread and thinking it > over, I realize that deprecation is the right way to go. Someone said that > it's useful when working with Excel. Excel uses bijective base-26 system. > PHP does not. I cannot even explain what logic governs PHP string increment > functionality. The logic is actually fairly straightforward if you consider breaking the original string into blocks of alpha, numeric and non-alphameric characters; so a string like 'C-37AZ99' would be broken into five blocks of characters ('C', '-', '37', 'AZ' and '99'). Start with the rightmost block, but only if its alpha or numeric: the process will never increment any block of characters that is non-alphameric. Increment the current block. If that increment would result in an overflow (extending the size of that block) and there is another block to the "left" in the chain of blocks, then that block is reset to its "base" value (discard the overflow character), and the same process is repeated for incrementing the next block in the chain. The process terminates when there are no more blocks in the chain, or when the process encounters a non-alphameric block. The string is then "glued" back together again for the return. In this regard, when a block is alpha characters, then the increment behaviour matches "Excel's bijective base-26". -- Mark Baker