Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:119339 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 20795 invoked from network); 18 Jan 2023 22:56:14 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 18 Jan 2023 22:56:14 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 168A61804AA for ; Wed, 18 Jan 2023 14:56:13 -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,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS29838 64.147.123.0/24 X-Spam-Virus: No X-Envelope-From: Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 18 Jan 2023 14:56:12 -0800 (PST) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 4FB3E3200946 for ; Wed, 18 Jan 2023 17:56:11 -0500 (EST) Received: from imap50 ([10.202.2.100]) by compute4.internal (MEProxy); Wed, 18 Jan 2023 17:56:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; h=cc:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm3; t=1674082570; x= 1674168970; bh=85E576nBgZXSdMFlFXMtXPWDyQDXRcbNfcGC883CU/M=; b=B 3tUa22L4S9faUH7iITY4JxYVP16Ge2rts7nFswwk2Ty/y1bBoyWf7oVPDMPvs9KV q7V+cp0RNWIDYHkmA0oCTUYQSLVNlMgS7fdPVNxZ204ueZTTPMkya1ESRNgWY14p sE4o21azOnpF3KBywYHNIm9/ygFST0LeemjQTiY7C7eWLqfHNQNWq1N5w4Ey2wUk jal9Fk2tkmX9Zp2y2DhRHyJ51BCVzs4FTgDIgHEJ3HiCtJA+Z8WKK2UJH2yzzDo6 izvUknuMu36KUS1S2KBEd8bueFQjIG5A9vqLkQxbqWHaHnnGKa7kDmRa84YIRmZw WmsLkLAIZoHCQRFw3KJxA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1674082570; x=1674168970; bh=85E576nBgZXSdMFlFXMtXPWDyQDX RcbNfcGC883CU/M=; b=MYU8sD13LHOa3D/xqmkUhmJArYkcYSzWhtQUkNRx0kNg psyZZR9RKGp1S9+ZvPcw66oXv1x8H8aJoWA+WrcXF3ubUxWJI5bqzJc2u3oqOI3K vslvH/wQwfcvpwysKN5r0RjjR84r1ZqbxoAnDrzWzx/JDw8CcAnNnMnmuDP8msqk W2r5EI0W8TS8dJgFhY44MRB8iE4bcPQCd4F2RE8UZA7EHgn9AqUyuqHdaiHQoUZ1 UJSmVqOZuGM6sFmQnTVpedYYfFuYMDg7BweyWI0ye+1e27FIiRKjfYY0VbIJDsTr /nzZfhcjqEGT1+fudGQld1rQxq3Vr0iVeHteHJK7lg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedruddtledgtdduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgesthdtredtreertdenucfhrhhomhepfdfnrghr rhihucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtoh hmqeenucggtffrrghtthgvrhhnpeeglefgkeduiedvvdetffeujefftdfhjeeiveehgfff keduveektddvledvvdfffeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmh grihhlfhhrohhmpehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomh X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id A31E71700090; Wed, 18 Jan 2023 17:56:10 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.7.0-alpha0-1187-g678636ba0d-fm-20230113.001-g678636ba Mime-Version: 1.0 Message-ID: <9283e65e-f25b-4de9-8fbc-f987c4ff7349@app.fastmail.com> In-Reply-To: References: <5FC8DBAF-8D78-4E94-A3B0-3BDED3A3E53C@craigfrancis.co.uk> <789af205-4582-66a9-694a-10e18b8b9f56@demon-angel.eu> <9d225219-4e31-b362-52a9-9a298a0a55ef@telia.com> Date: Wed, 18 Jan 2023 16:55:39 -0600 To: "php internals" Content-Type: text/plain Subject: Re: [PHP-DEV] [RFC] Path to Saner Increment/Decrement operators From: larry@garfieldtech.com ("Larry Garfield") On Wed, Jan 18, 2023, at 2:25 PM, G. P. B. wrote: > On Wed, 18 Jan 2023 at 16:03, Levi Morrison > wrote: > >> It seems to me that if you truly want to clean up this specific part >> of the language, you are going to have to play the long game: >> 1. New functions are added for the perl behavior of string increment >> and decrement. No warnings are given in code, but call-outs are made >> in upgrading and other documentation about this behavior changing. >> Note that in the past I would have used an E_STRICT for this, but >> people seem opposed to adding new E_STRICT warnings. >> 2. In the next minor version, we add a warning about the behavior >> when string increment/decrement is used. >> 3. In the next major version, we finally clean up the behavior. >> >> But this gets muddy if we do PHP 8.3 for step 1, and then we decide to >> go for PHP 9.0 instead of 8.4, and it messes with the "ideal" cycle. >> >> Note that I support this sort of plan, and would support it for >> cleaning up many other parts of PHP as well. It's just unfortunate it >> takes so long, but that's how it goes sometimes :/ > > > I don't think we need such a long timeline because the function is easily > poly filled. > Moreover, if people jump a version in an upgrade, they are still going to > immediately receive a warning/deprecation. > But if such a timeline is preferred, I do not mind changing it. > > On Wed, 18 Jan 2023 at 18:33, Alex Wells wrote: > >> Classes and methods is the expected way of implementing standard library in >> an OO language. New APIs (such as the new Random api) use OO instead of >> functions and it makes more sense to use OO in this case too: there's >> likely a place for other methods too, like toBase(int $otherBase) etc. It >> would also be possible to use overloaded operators if needed. > > > Until we have strings that can invoke methods, I don't see the point of > having an OO API. > PHP is a multi paradigm language, and creating a class with two methods > seems very useless to me. > OOP is favoured in PHP because using functions is just an overall terrible > experience that needs improvements, but using functional patterns is > totally doable (and can produce elegant code) in PHP. > > George P. Banyard I agree that adding a str_increment() function and then (later) deprecating and removing the ++ functionality is the way to go. I defer to George if it makes sense to fix the other parts of ++ now and wait for 9 for string-incrementing, or just wait and get rid of them all at once. While str_increment() is less ergonomic than ++, I think the improved type consistency is worth it. And it's trivial to wrap up into a generator if one wants something shorter: function cols(string $s): \Generator { while (true) { $s = str_increment($s); yield $s; } } $it = cols('A'); $it->next(); // gives B And that can be made parallel with something on the number side if you really want. --Larry Garfield