Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:119308 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 52863 invoked from network); 18 Jan 2023 14:36:13 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 18 Jan 2023 14:36:13 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id E506D180088 for ; Wed, 18 Jan 2023 06:36:10 -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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS3301 81.224.0.0/12 X-Spam-Virus: No X-Envelope-From: Received: from ts201-smtpout72.ddc.teliasonera.net (ts201-smtpout72.ddc.teliasonera.net [81.236.60.177]) (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 06:36:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telia.com; s=tssemail-202204; t=1674052570; bh=IKRP1E1V/LJoYLaXTkINoQtyYPaxLbWLNJPurTyfCtI=; h=Message-ID:Date:MIME-Version:Subject:To:References:From:In-Reply-To; b=Pq5dfX4yfbGnu+4MTA0/GbcVyl/AdXkqfQCbszQqHpO9AAEtDsXiJE/A7hak1Cl6BCCT780Ol/pCgOE3+GqStkCJPsxHKvQ0/g39V5uGXGXx1JELY7XQMASreGSsWwGx67YSVWFAvHBkkoEJjM1DIOpkvLSG36KZfO0AzbPgIfGE5cR0ZuiYfPC+JIWxqtnJ+arBxU/8pA9VGpPVjI0AxZULu4rL7G37Jbw8zF7C35rNKROvTxbPEhOfrtozVyf5KEnfRvPNTYTNs1tSNYldxi/6UVDDgXOfuxfh+Keo4cnXEkE3wNRJHlIuTBtez2mQyDySBbQGoNwkGgb1pU8DZA== X-RG-Rigid: 63C25935001FFD06 X-Originating-IP: [84.216.97.240] X-RazorGate-Vade: gggruggvucftvghtrhhoucdtuddrgedvhedruddtkedgieeiucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuvffgnffktefuhgdpggftfghnshhusghstghrihgsvgdpqfgfvfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhepkfffgggfuffvvehfhfgjtgfgsehtkeertddtfeejnecuhfhrohhmpeeujhpnrhhnucfnrghrshhsohhnuceosghjohhrnhdrgidrlhgrrhhsshhonhesthgvlhhirgdrtghomheqnecuggftrfgrthhtvghrnhepleduvddugfevudettddujedtueffleehtefhiefhteehtdetueekteeiuefgffdunecuffhomhgrihhnpehphhhprdhnvghtnecukfhppeekgedrvdduiedrleejrddvgedtnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehhvghloheplgduledvrdduieekrddurdeingdpihhnvghtpeekgedrvdduiedrleejrddvgedtpdhmrghilhhfrhhomhepuhekleeltdeigedujeesphhnvgdrthgvlhhirgdrtghomhdpnhgspghrtghpthhtohepfedprhgtphhtthhopehgvghorhhgvgdrsggrnhihrghrugesghhmrghilhdrtghomhdprhgtphhtthhopehinhhtvghrnhgrlhhssehlihhsthhsrdhphhhprdhnvghtpdhrtghpthhtohepmhgrrhhkseguvghmohhnqdgrnhhgvghlrdgvuh X-RazorGate-Vade-Verdict: clean 0 X-RazorGate-Vade-Classification: clean Received: from [192.168.1.6] (84.216.97.240) by ts201-smtpout72.ddc.teliasonera.net (5.8.716) (authenticated as u89906417) id 63C25935001FFD06; Wed, 18 Jan 2023 15:35:57 +0100 Message-ID: <9d225219-4e31-b362-52a9-9a298a0a55ef@telia.com> Date: Wed, 18 Jan 2023 15:35:57 +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: sv To: "G. P. B." , Mark Baker Cc: php internals References: <5FC8DBAF-8D78-4E94-A3B0-3BDED3A3E53C@craigfrancis.co.uk> <789af205-4582-66a9-694a-10e18b8b9f56@demon-angel.eu> Reply-To: =?UTF-8?Q?Bj=c3=b6rn_Larsson?= In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] [RFC] Path to Saner Increment/Decrement operators From: internals@lists.php.net ("Björn Larsson via internals") Den 2023-01-18 kl. 13:22, skrev G. P. B.: > On Tue, 17 Jan 2023 at 18:28, Mark Baker wrote: > >> On 17/01/2023 17:28, Craig Francis wrote: >>> I've seen this used a few times, e.g. starting with a numerical value >> (Passport number, NHS number, Social Security Number, Date of Birth >> 20230117), and the developer simply appends an incrementing letter on the >> end to get a unique reference; e.g. a person having multiple assessments... >> especially if it's more than 26 (A-Z), and you need to move to multiple >> letters, which `chr(90 + 1)` cannot help you with. >> >> Being able to increment alpha strings is incredibly useful when working >> with Excel spreadsheets (as I do on a daily basis), because the column >> Ids match this pattern; and I would hate to see this deprecated. Having >> to replicate that logic for traversing column Ids in userland code would >> be inconvenient (to say the least), would affect many of the users of my >> libraries, and would have a performance impact on my libraries. If >> anything, I'd rather like to see the decrement operator work with alpha >> strings as well for more consistency. >> >> I don't have the karma for a vote; but if I did then it would be a "No" >> for this alone, because I can see the problems that it will cause me and >> the users of my libraries. >> >> >>> That said, I appreciate that incrementing some strings can be a bit >> unusual (e.g. "A9" to "B0", vs "A 9" to "A 0"). >> >> Agreed. While incrementing works in a very logical manner with mixed >> alphanumeric strings, it's not well documented behaviour, and most >> developers take a long time before they understand what it's actually >> doing. While there might be use cases for incrementing alphanumerics, I >> suspect that it would be better implemented in the business logic of an >> application, because the component parts of that string are likely to >> have business meaning; and also to provide better code readability. >> > > I appreciate being shown concrete cases about the useful ness of this > operation. > The reason I didn't go with adding support for decrementing alphanumeric > strings is that it was unanimously rejected. > However, if Rowan's suggestion of adding > string_increment()/string_decrement() with more rigorous behaviour (that we > can flesh out together) would be part of this proposal, would you be more > inclined to accept deprecating ++ from performing this feature? > > I truly believe having $v++ behave like $v += 1 and $v-- behave like $v -= > 1; is something to strive for *because* it allows us to remove one > dedicated type juggling context people need to be aware of and simplifies > the overall semantics of the language. > Keeping support for string increments means that one cannot interchange $v++ > and $v += 1 and that one needs to be aware about using it when a value > might hold a string. > As such, if it needs to remain its own type juggling context, the question > is why not make it stricter by having it warn and then throw a TypeError on > bool, reopening the can of worms that is the null handling between both > operators and what to do with the empty string case. > These questions are already answered by making those operators behave just > like addition/subtraction. > > My order of preference for the semantics are as follows: > 1. The behaviour described in the RFC (with or without function for string > in/decrement) > 2. (with a massive gap, but I could live with it) adding support for string > decrements and tiding up the behaviour of the alphanumeric string to make > it stricter and less error-prone. > 3. The current asymmetry (again with a massive gap between this and option > 2) > > But because option 2 seems out of the question due to the unanimous > rejection of https://wiki.php.net/rfc/alpanumeric_decrement, the only > viable options to me seem like 1 and 3. > As I hate option 3 I am pushing for option 1 as I think it has various > benefits. Since the alpanumeric_decrement RFC was rejected january 2014 9 years ago, could it be an option to bring it up again in conjunctione with your RFC? Maybe the added value of your RFC could swing the opinion. I mean there has been RFC's that required multiple tries to fly. Regards //Björn L