Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:119334 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 7600 invoked from network); 18 Jan 2023 20:25:18 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 18 Jan 2023 20:25:18 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id ACFA6180551 for ; Wed, 18 Jan 2023 12:25:17 -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,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.178]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 18 Jan 2023 12:25:17 -0800 (PST) Received: by mail-pg1-f178.google.com with SMTP id r18so25384855pgr.12 for ; Wed, 18 Jan 2023 12:25:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=YbtUDW/y4eLEtJ/VLmQdyA5No3vN7dje0BtcsAUHqIc=; b=n/O5S92SR3YN3YNWRacHI76uDMtEbRElwRRBEeLNAlAwWAkoIloy874XUlfVjqlWKL /7XAE7ISyuk9VEw4LKvRXBpN4f/KPgt3spI+aJwObNaBHhdKdvlBn7rKd+y7kYAoBuqH mM5xBGVMwiaxD1i+BSCdq+W70z9iT27BydeYpvEPUljSuPp4ZbeXu61osjAoZTx9+3LF f4YRXFK0BfwmIl+28ZFnjdas8Jb5hnJDQGRGdw/Zi3ZTzqgrcXEX4MFz71saMLzXS5Q1 VjE9f3K0w7HpxoQWEi6jQF2CiLlmdVoyvFLo+xvDDDsow5SdLDZGWjvrZKo9J4NWP7n8 Xkiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=YbtUDW/y4eLEtJ/VLmQdyA5No3vN7dje0BtcsAUHqIc=; b=lPlpi/VumnEt3ZfdhSeGL2zWcW1Q3ag5kOIYmiT7fYRgGxDyK5OMSItts+YvU21xGm tJ5np5cs32KXmx2m31+7dJlHHByGTy1LNdNZBk5MmUpT744r5GLBF2vddiiql0Z2N7l1 pmhgJiJOKHJGui73KT4e+cA2aZicHV0jMVM+d7kf2dJ5+yBRrqp88iLo/fVfR0E4NAil RWateaUkdy1o6rD1pECOGFzlFmlf2hEmdL3EpV0c7grqKpc/9emAynwr3xpHQT7ygAeP lS3qZBhqgj32CyFSuRBVTaryEEmnwoYD+ptx1Kst17dyVo+gxsJ7YB/1FpItPCXDHji4 luaA== X-Gm-Message-State: AFqh2kq8GgU973mUHyKjChCc07La32hOwhVa/JWBkU+mBHTuTsdKvVPM qBPBQW8z+f0s+De5GoKt/lH/VbWR91qKnfcCT4z7QJV1cZA= X-Google-Smtp-Source: AMrXdXtl9xLGeSusEpHlwGmO87Ysq+tlCkX7+4SWp9PIcbwwgDs6/EX87dc5J8Nahiz+qvfhrZ0eOAZA6vyO/uqE1Mk= X-Received: by 2002:a05:6a00:1d23:b0:58d:b662:af11 with SMTP id a35-20020a056a001d2300b0058db662af11mr704198pfx.37.1674073516008; Wed, 18 Jan 2023 12:25:16 -0800 (PST) MIME-Version: 1.0 References: <5FC8DBAF-8D78-4E94-A3B0-3BDED3A3E53C@craigfrancis.co.uk> <789af205-4582-66a9-694a-10e18b8b9f56@demon-angel.eu> <9d225219-4e31-b362-52a9-9a298a0a55ef@telia.com> In-Reply-To: <9d225219-4e31-b362-52a9-9a298a0a55ef@telia.com> Date: Wed, 18 Jan 2023 20:25:04 +0000 Message-ID: To: php internals Cc: =?UTF-8?Q?Bj=C3=B6rn_Larsson?= , Derick Rethans , Levi Morrison , autaut03@gmail.com Content-Type: multipart/alternative; boundary="0000000000003feb0305f28f9dcb" Subject: Re: [PHP-DEV] [RFC] Path to Saner Increment/Decrement operators From: george.banyard@gmail.com ("G. P. B.") --0000000000003feb0305f28f9dcb Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, 18 Jan 2023 at 14:35, Bj=C3=B6rn Larsson wrote: > 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 h= as > been RFC's that required multiple tries to fly. > Possibly, and I could wait for the result of such an RFC, but I do not intend on pushing this forward. On Wed, 18 Jan 2023 at 15:32, Derick Rethans wrote: > On Tue, 17 Jan 2023, G. P. B. wrote: > > > I would like to start the discussion on the Path to Saner > > Increment/Decrement operators RFC: > > https://wiki.php.net/rfc/saner-inc-dec-operators > > > > The goal of this RFC is to reduce language complexity by making $v++ > > behave like $v +=3D 1 and $v-- behave like $v -=3D 1; > > If that is the goal, then I would agree with this RFC. > > However, changing the PERL string increment feature does not IMO fit > into that goal, and it also a useful *feature*. On that base I would > vote against this. And I suspect many others would as well. > I do not understand how this does *not* fit into that goal. $s =3D "a10"; $s +=3D 1; var_dump($s); Results in a TypeError whereas $s =3D "a10"; $s++; var_dump($s); Results in string(3) "a11" Therefore, $s++ does not behave like $s +=3D 1; and thus in scope. Is there a way to avoid this single useful feature from being > deprecated, while to good parts of this RFC stay? > Yes, but at that point, I don't see why we should unify the behaviour if it is going to remain inconsistent. Might as well make incrementing on bool, and decrementing null a TypeError in PHP 9 to make it stricter. > I am also unsure as how much actual breakage this would cause, and > before this gets up to a vote, I would like to see how bad (or not) this > would affect already existing code bases. > Fair point, I can try and run Nikita's script on the top composer packages, but that won't show the state of private codebases. 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 --0000000000003feb0305f28f9dcb--