Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127461 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by lists.php.net (Postfix) with ESMTPS id 8BE671A00BC for ; Mon, 26 May 2025 14:37:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1748270145; bh=6jJS3toeBBpCljowfW0WFAITK/Hj49hKIGkHFQI7GGc=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=aMZO/n/J3sXvyuhJhVTlBubiklFXTK8RYOknvVfEl8Ge1Asv8nnd5Bpr4DkESPpuE 72o6O2Ecpn+hiyDSBHOnL8kGip7m3+XiGBoX3RxYtIyR0S1hd7zBUB+Qy0XmWKQzxA aDJ87NwdZNhyPWY894LbyBUj40r4CePhgpcnIwwt7NHWZ0PupZ9AoJVwruQuUqhq1K 3F6rze7w12AJihCMEvSW+yFUA85WA9BtT5CXe9hP0XALbhAHsJTJCadoMg4bvECNSt 8R1vKvcr8vffDvGPiHps9LRTRr7hGno9apTyuuHPYq9GnRS7c2590mfMovTWH7bcrx S3uPyEu3jiafA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 944BF18006A for ; Mon, 26 May 2025 14:35:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_20,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com [209.85.208.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 26 May 2025 14:35:44 +0000 (UTC) Received: by mail-lj1-f177.google.com with SMTP id 38308e7fff4ca-32a63ff3bdfso5539021fa.3 for ; Mon, 26 May 2025 07:37:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1748270270; x=1748875070; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=XVWywgr2cM2usHle2/lhW+IHzMgrj4MlGS+1euo//S8=; b=X5EQzKhdJk2KM5U1zSC9hOlVVmmpw4O2EUPcIsd7xYdBOZAESV7uIaorl2LE+PL7vt X/G1wTMeQARh5EiQ7JgsYAOqrcU0gr4+HzWm7ivRaUnPq6b6PQOoyuz2fqG4B7c14bQO o5l0VHMjAhgOFYV57+0LojnYs3GhQ2i+1U3ejUEJOCaka3wP8DMuhgzq0/NlCM7osiV4 lVFIvnnm73Sucqbhalgm3ald2MOQMs2FGEyXACa5j0RSRHRaushqL2tJ7cSMZhPBXdyU UCvxTJAoLz/ab1w+toUzP/feryRLXliwAbkCMdSMq8QdUS+efjkCBi4A52A3PZtVTJt2 Q03g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1748270270; x=1748875070; 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=XVWywgr2cM2usHle2/lhW+IHzMgrj4MlGS+1euo//S8=; b=N+KFlCBXa3fp0cavzNxmVebBQ70cm0HN7Ji53ekAUHWEZZU41vJGHzQ1xj5wtiB+XK Ka/7CeZ+gfwmNdAhmhHGlxruLcGOaYUqAZ2DrU8TOcj3DdHr+6TzVUyC9nz0j6e1mgOt EnhC2JWrMVIC7j78IkmyNT4iWneX7Dk1fYOW/oyMXGeQasjW517+QsEX0NodhjQzVGPl 4/Vsi75zfi0uXPw8CBSWFtdeQPSF/Ht1DTiq+dOwliBFl3Sc1V5/VXfBQcURnx1pL81a anYFp6O4dl5kgLM0ZA75uGmvm2CAFL24H2QZWfOZSzo6bXhz8VpOFBMdyyJZo0tJAD4L VM6A== X-Gm-Message-State: AOJu0YwBxyOTXpZxZTAIaD5nVqRGcxG6qs13mEQSBcJgTFMwLoe4S78E ex3EkWhAYe5ywuZbTlLy/vJT5zwFm2iXq1FWaTaURBzpeYxUc83n9aNWyLSyZAdXxM7G+Fa4jeq I9f3U9zHBJ5Vqc3Zw7MTAZNbM7ttllH0= X-Gm-Gg: ASbGncvDgNjZAJxwduW7k3biESuYBF0HQrHW6TSSWsQVZ0VuLf7QymtvhrL8xw6+svO a5wsunWBE5+TC3Haay3aEt5RSaOzfwT8QEwchjE7STU3EhdenBrpu8B284+E9+wccGH7LqkcF34 I+0uB1CEiY/S4qzibMRsp4ajl79lJfolcNTO5vBR1T22U= X-Google-Smtp-Source: AGHT+IFexs976rhHzw0ERe4e5Ld02YMufG8aQKLP+vsOc11XHq8P2P/Q5u+egZz1pK8QLoTHuXXi49wYuPNpNa+3PWc= X-Received: by 2002:a05:651c:19a1:b0:30b:c96a:750 with SMTP id 38308e7fff4ca-3295b9aaa34mr26549941fa.1.1748270269346; Mon, 26 May 2025 07:37:49 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 26 May 2025 16:37:37 +0200 X-Gm-Features: AX0GCFtotF-JzuE9TSxBIXYJCO9kwaNFKrvBlFZk4_dSCJrSpaLGt0SYTR0ig8g Message-ID: Subject: Re: [PHP-DEV] Re: [RFC] Clone with v2 To: Volker Dusch Cc: php internals , =?UTF-8?Q?Tim_D=C3=BCsterhus?= Content-Type: multipart/alternative; boundary="0000000000006038a206360ae454" From: nicolas.grekas+php@gmail.com (Nicolas Grekas) --0000000000006038a206360ae454 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Volker, Thanks for the update. Le lun. 26 mai 2025 =C3=A0 16:05, Volker Dusch a =C3=A9crit : > Version 1.1 Update: Array syntax over named arguments. > > Thank you everyone for the discussion and for improving this RFC. I'm ver= y > happy with the updates we made thanks to your feedback on and off list. > > The main idea of this RFC was to have as little of a footprint as possibl= e > and make it feel natural in PHP. I got carried away a bit during writing > this, and by using named arguments, introduced something that isn't used = in > php-src provided functions, had edge cases that required documentation, a= nd > all in all, didn't feel natural in PHP but like an inconsistency. PHP use= s > arrays to pass lists everywhere else, so changing this here feels like to= o > much scope for this little change. I'm very happy this was caught and > raised in the discussions. Thank you. > > If there is desire for named-parameter-as-an-array syntax this should be > standalone RFC with more scope than a single function. > > We've updated the RFC and the implementation, removing the "Open Issue" > listed before, as this change resolved all of them. > > - https://wiki.php.net/rfc/clone_with_v2 > - https://github.com/TimWolla/php-src/pull/6 > To me, it would have made more sense to still make "clone" an operator but I think we can all get used to the array style, so if the majority thinks arrays should be the way to go, so be it. I think the RFC is missing a few bits to be complete: - making "clone" a function means suddenly a "use clone;" or a "\clone" is going to be needed to not get a perf hit, isn't it? But since $y =3D clone $x; is still going to be valid, how will this be handled? The RFC could give some more hints on the topic. - writing code with a wide range of supported PHP versions means we'll start using construct such as: if (PHP_VERSION_ID>=3D80500) { $b =3D 'clone'($a, [...]); // note 'clone' is a string here, so that the line is valid syntax on PHP <=3D 8.4 else { // another code path for PHP 8.4 } That's of course because "use clone", "\clone" or "clone($foo)" is invalid PHP syntax currently. It could make sense to tell about this and show an example like this one in the RFC. - what if one gives a mangled property in the array? clone($foo, ["\0Foo\0bar" =3D> 123]) It could be useful to write something about this case and/or at least have a test case that shows how this should behave. - To me, the main technical drawback of the RFC is that it builds on mandatory deep-cloning, which means wasted CPU/mem resources by design. This has to be mentioned in the RFC IMHO so that voters can make an informed decision. About this last point, it's the one that makes me undecided about my voting decision on the RFC. I shared my concern and a solution in another thread, where I also address the BC concern that is mentioned in the RFC. Since this concern has been addressed, I think this should be considered more closely. As is, that's a big omission to me - recognizing and addressing the issue with deep-cloning= . Cheers, Nicolas --0000000000006038a206360ae454 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Volker,

= Thanks for the update.

Le=C2=A0lun. 26 mai 2025 = =C3=A0=C2=A016:05, Volker Dusch <volker@tideways-gmbh.com> a =C3=A9crit=C2=A0:
Version 1.1 Update: Array syntax over named arguments.

Thank you everyone for the discussion and for impro= ving this RFC. I'm very happy with the updates we made thanks to your f= eedback on and off list.

The main idea of this RFC= was to have as little of a footprint as=C2=A0possible and make it feel nat= ural in PHP. I got carried away a bit during writing this, and by using nam= ed arguments, introduced something that isn't used in php-src provided = functions, had edge cases that required documentation, and all in all, didn= 't feel natural in PHP but like an inconsistency. PHP uses arrays to pa= ss lists everywhere else, so changing this here feels like too much scope f= or this little change. I'm very happy this was caught and raised in the= discussions. Thank you.

If there is desire for na= med-parameter-as-an-array syntax this should be standalone RFC with more sc= ope than a single function.

We've updated=C2= =A0the RFC and the implementation, removing the "Open Issue" list= ed before, as this change resolved all of them.


<= br>
To me, it would have made more sense=C2=A0 to still make &quo= t;clone" an operator but I think we can all get used to the array styl= e, so if the majority thinks arrays should be the way to go, so be it.

I think the RFC is missing a few bits to be complete:<= /div>

- making "clone" a function means sudden= ly a "use clone;" or a "\clone" is going to be needed t= o not get a perf hit, isn't it? But since $y =3D clone $x; is still goi= ng to be valid, how will this be handled? The RFC could give some more hint= s on the topic.

- writing code with a wide range o= f supported PHP versions means we'll start using construct such as:
if (PHP_VERSION_ID>=3D80500) {
=C2=A0=C2=A0 $b =3D '= ;clone'($a, [...]); // note 'clone' is a string here, so that t= he line is valid syntax on PHP <=3D 8.4
else {
=C2= =A0=C2=A0 // another code path for PHP 8.4
}
That's= of course because "use clone", "\clone" or "clone= ($foo)" is invalid PHP syntax currently.
It could make sense= to tell about this and show an example like this one in the RFC.

- what if one gives a mangled property in the array? clone(= $foo, ["\0Foo\0bar" =3D> 123])
It could be useful to= write something about this case and/or at least have a test case that show= s how this should behave.

- To me, the main techni= cal drawback of the RFC is that it builds on mandatory deep-cloning, which = means wasted CPU/mem resources by design. This has to be mentioned in the = RFC IMHO so that voters can make an informed decision.

=
About this last point, it's the one that makes me undecided about = my voting decision on the RFC.
I shared my concern and a solution= in another thread, where I also address the BC concern that is mentioned i= n the RFC. Since this concern has been addressed, I think this should be co= nsidered more closely. As is, that's a big omission to me - recognizing= and addressing the issue with deep-cloning.

Cheer= s,
Nicolas
--0000000000006038a206360ae454--